2014-02-20 56 views
3

我使用Selenium :: Remote :: Driver模块。我试图使用perl语言来最大化/最小化浏览器窗口。我可以将窗口大小设置为特定的坐标,但不能完全最大化和最小化。所以请帮助我做到这一点。我的代码如下:如何在perl脚本中使用Selenium Remote Driver最大化/最小化Firefox浏览器窗口

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'); 

在这里,我得到错误为‘通过包‘“无法找到对象的方法’屏幕宽度硒::远程::驱动程序’

能否请你建议我如何最大化或使用硒远程驱动器最小化浏览器窗口

代码编辑:

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

对不起它是笔误,应该是这个样子而1920和1680是我们逝去,但所发生的事情是窗口的尺寸是不恰当的屏幕没有最大化完全

+0

您还没有定义'screenwidth' ......那么,是它从何而来? – Arran

+0

@Arran编辑后请检查代码 – santoshi

回答

0

不幸的是,Selenium::Remote::Driver不提供最大化方法,但其他Selenium模块用于Perl。

如果切换到WWW::Selenium,你就可以使用window_maximize

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