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

Hi monks ! Iam note sure it's totally a Perl question but i try my luck: I am doing some little tests using Selenium::Remote::Driver package. I would like now to COMPARE some screenshots amongst themselves with Selenium::Screenshot module. But my screenshots have different size. How can i do this ? Code example :
my $driver = Selenium::Remote::Driver->new; $driver->set_window_size(320, 480); $driver->get('http://www.google.com/404'); my $white = Selenium::Screenshot->new(png => $driver->screenshot); # Alter the page by turning the background blue $driver->execute_script('document.getElementsByTagName("body")[0].styl +e.backgroundColor = "blue"'); # Take another screenshot my $blue = Selenium::Screenshot->new(png => $driver->screenshot); unless ($white->compare($blue)) { my $diff_file = $white->difference($blue); print 'The images differ; see ' . $diff_file . ' for details'; }
Thanks to everyone !

Replies are listed 'Best First'.
Re: Selenium Screenshot
by Athanasius (Archbishop) on May 24, 2016 at 12:02 UTC
      Hey ! Thanks. I will see that
      I have another question if you would like to take 2 mins. I have this following method :
      $elem = $driver->find_element('app-lgs','id' ); Selenium::Screenshot->new( png => $driver->screenshot, exclude => [{ size => $elem->get_size, location => $elem->get_element_location, }] )->save( file => "screen.png" );
      But there is no example added to describe how to use it. I tried code below but it doesn't work:
      Selenium::Screenshot->new( png => $driver->screenshot, exclude => [{ size => { width => 10, height => 10 } location => { x => 5, y => 5 }, }]
      Have you got an example to purpose me ? Thanks again !

        The documentation of Selenium::Screenshot discusses what the parameters are for. Which parts of the documentation are unclear for you?