如何在启动 Selenium Remote Control 期间调整 Firefox 窗口大小/最大化?
我正在使用 Selenium 远程控制 。在执行测试期间,实际的 Firefox 窗口非常小。我希望它全屏显示,这样我就可以看到正在发生的事情。如何最大化浏览器屏幕?
I am using Selenium Remote Control . During executing the tests the actual Firefox window is so small. I want it full screen so I can see what is happening. How can I maximize the browser screen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
尝试 windowMaximize 命令:
您还可以使用以下命令设置特定的宽度和高度:
其中 X 是宽度,Y 是高度。
Try the windowMaximize command:
You can also set a specific width and height using the following command:
Where X is the width and Y is the height.
这对我有用。所有其他解决方案在 FF7 中均不起作用。
This works for me. All the other solutions didn't work in FF7.
您可以执行以下操作:
You can do the following:
硒2.31.0
Selenium 2.31.0
对于火狐浏览器:
sel.key_press_native(122)
(F11 的按键代码为 122)
for Firefox:
sel.key_press_native(122)
(122 in the key code for F11)
好吧,我认为最好的方法是使用 selenium.windowMaximize() selenium 函数而不是操纵窗口大小。
Well I think the best way is to use selenium.windowMaximize() selenium function instead of manipulating the windows size.
将 -singlewindow 参数传递给 Selenium RC 服务器时,提供的所有答案都不起作用。但是,如果您将 Firefox 配置文件传递到 Selenium RC 服务器 (详细说明如下),您可以创建一个空的配置文件文件夹并将此文件放入该文件夹中:
localstore.rdf(区分大小写的文件名!):
将宽度和高度替换为您首选的宽度和高度。 9999x9999 几乎可以最大化任何显示器。
以这种方式运行 Selenium RC 服务器的最简单的示例假设我们的主目录中有前面提到的 localstore.rdf,并且我们当前位于 Selenium RC 服务器的目录中:
这也有不“污染”您的测试的额外好处。
None of the answers provided work when passing the -singlewindow parameter to the Selenium RC server. However, if you pass a firefox profile to the Selenium RC server (as detailed somewhat here), you can make an empty profile folder and put this file in the folder:
localstore.rdf(case sensitive filename!):
Replace width and height with your preferred width and height. 9999x9999 will pretty much maximize any monitor.
The simplest example possible of running your Selenium RC server this way assuming we have the previously mentioned localstore.rdf in our home directory, and we are currently in the directory of the Selenium RC server:
This also has the added benefit of not "polluting" your tests.
为了扩展 David Hunt 关于更具体的窗口大小调整和移动的建议,请注意以下内容。
要在大多数环境中工作,请在调整大小之前先移动。那是:
覆盖屏幕的 2/3,这对于查看下面的 selenium 驱动窗口的一部分很方便,并且可以执行以下操作无论您的目标屏幕分辨率如何:
To expand on David Hunt's suggestion for more specific window resizing and moving note the following.
To work in most environments move before resizing. That is:
To cover 2/3's of the screen, which is handy for seeing part of the selenium driving window underneath, and to do this regardless of your target screen resolution:
在 ruby 中,调用将是
In ruby, the call would be