简体   繁体   English

如何在perl脚本中使用Selenium Remote Driver最大化/最小化firefox浏览器窗口

[英]How to maximize/minimize the firefox browser window using Selenium Remote Driver in perl scripting

I am using Selenium::Remote::Driver module. 我正在使用Selenium :: Remote :: Driver模块。 I am trying to maximize/minimize the browser window using perl language. 我正在尝试使用perl语言最大化/最小化浏览器窗口。 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 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" 在这里我得到错误为“无法找到对象方法”screenwidth“通过包”Selenium :: Remote :: Driver“

Can you please suggest me how to maximize or minimize the browser window using selenium remote driver? 您能否建议我如何使用selenium远程驱动程序最大化或最小化浏览器窗口?

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 对不起,这是错字,应该像这样,1920年和1680年是我们正在通过的尺寸但发生的事情是窗口不适合屏幕没有完全最大化

Unfortunately, Selenium::Remote::Driver does not provide a maximize method, but other Selenium modules for Perl do. 不幸的是, Selenium :: Remote :: Driver没有提供最大化方法,但Perl的其他Selenium模块也没有。

If you switch to WWW::Selenium , you'll be able to use window_maximize : 如果你切换到WWW :: Selenium ,你将能够使用window_maximize

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Perl脚本中使用Selenium远程驱动程序在Firefox浏览器中打开新标签页? - How to open a new tab in a firefox browser using selenium remote driver in perl scripting? 无法在Perl脚本中使用Selenium远程驱动程序从drodownlist中选择一个选项 - Unable to select an option from drodownlist using selenium remote driver in perl scripting 如何在Perl中使用Selenium :: Remote :: Driver到达页面的底部? - How to reach the buttom of the page using Selenium::Remote::Driver in perl? 如何在Perl中使用Selenium :: remote :: driver在弹出窗口上单击按钮? - how to click a button on popup using selenium::remote::driver in perl? 如何在使用Selenuium :: Remote :: Driver的Perl脚本中从网页的下拉列表中选择一个选项 - How to select an option from dropdownlist of a webpage in perl scripting using Selenuium::Remote::Driver 在Perl中使用Selenium :: Remote :: Driver查找问题的元素 - Issue finding elements using Selenium::Remote::Driver in Perl 使用 Perl Selenium::Remote::Driver for Javascript 稍后加载页面 - Using Perl Selenium::Remote::Driver for Javascript that loads page later 如何使用Selenium :: Remote :: Driver Perl软件包通过Open Windows在测试中上传文件 - How to upload a file in a test through Open Windows using Selenium::Remote::Driver Perl package 如何使用Perl的Selenium :: Remote :: Driver返回WebElement的文本? - How do I return the text of a WebElement using Perl's Selenium::Remote::Driver? 如何使用 Selenium::Remote::Driver 抑制“警告”? - How to suppress “warning” using Selenium::Remote::Driver?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM