Chaoui05 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks !! I am beginner and it's a real easy question. My issue is : I would like to get in a variable this path ($driver->capture_screenshot("D:/dev/drivers/snap-$browser.png"); ) to not have to write  D:/dev/drivers every time I tried to do this :
my $path; $path->capture_screenshot{}
And    $driver->capture_screenshot($path =>"snap-$browser.png");

Many Thanks !!

Replies are listed 'Best First'.
Re: Set a screenshot from Selenium package in a variable
by Corion (Patriarch) on Apr 27, 2016 at 13:31 UTC

    Why don't you do what you do for $browser also for the path?

      Here what i did for $browser :
      my $self = shift; $self->{browsers} = [('chrome', 'phantomjs', 'firefox', 'internet ex +plorer')];

      and

      my $driver = Test::Selenium::Remote::Driver->new( browser_name => $bro +wser );
      For snap's name i know but to do it with path i don't know how . And what are my issues with my forward code ?! Thanks again !

        You have the following code:

        $driver->capture_screenshot("D:/dev/drivers/snap-$browser.png");

        There, you use the $browser variable to construct a part of the filename.

        You can do the same for other parts of the filename:

        my $target = "D:/dev/drivers/"; $driver->capture_screenshot("$target/snap-$browser.png");