3
votes

I am using Selenium::Remote::Driver module. I am trying to maximize/minimize the browser window using perl language. I can set the window size to a particular coordinates but not fully maximized and minimized. So please help me to do this. My code is as below:

maximize.pl

use strict;
use warnings;
use Selenium::Remote::Driver;
my $driver = new Selenium::Remote::Driver;

$driver->get("https://www.google.co.in/");
$driver->set_implicit_wait_timeout(40000);
$driver->set_window_size($driver->screenwidth, $driver->screenheight,'current');

Here I am getting error as "Can't locate object method "screenwidth" via package "Selenium::Remote::Driver"

Can you please suggest me how to maximize or minimize the browser window using selenium remote driver?

code edit:

$driver->set_window_size(1920, 1680,'current');

Sorry it is typo and should be like this and 1920 and 1680 are the dimensions which we are passing but what happened is window is not fitting to the screen not maximizing completely

1
You haven't defined screenwidth ...so where is it supposed to come from? - Arran
@Arran please check the code after editing - santoshi

1 Answers

0
votes

Unfortunately, Selenium::Remote::Driver does not provide a maximize method, but other Selenium modules for Perl do.

If you switch to WWW::Selenium, you'll be able to use window_maximize:

use WWW::Selenium;
my $sel = WWW::Selenium->new( ... );
$sel->start;
$sel->open("https://www.google.co.in/");
$sel->window_maximize()