如何使用Selenium RC关闭或最小化浏览器窗口? [英] How to close or minimize browser windows with Selenium RC?

查看:2247
本文介绍了如何使用Selenium RC关闭或最小化浏览器窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我通过Selenium RC启动一个Firefox实例时,我得到了3个窗口,我不需要出现这个窗口:



我不需要其中的任何一个,每次我必须手动关闭加载项窗口,最小化另外两个窗口,并使Selenium控制的主浏览器窗口最大化。经历了这么多次后,我感到非常恼火以寻求解决方案:

是否有任何方法可以自动关闭附加组件窗口并最小化另外两个窗口?



顺便说一下,我在OS X上,所以我也很感激一些替代的解决方案,通过操作系统自动化这个,而不是直接使用Selenium。

解决方案

您可以在自定义配置文件中更改一些首选项,以防止添加窗口和附加选项卡startup:


  1. 设置 extensions.lastAppVersion 首选项为您的Firefox版本
  2. extensions.newAddons 首选项设置为 false

  3. extensions.update.notifyUser 首选项设置为 false 。 >

可能还有一些,或许其他人可以在评论中提供他们的建议eir自己的答案。

只要Selenium运行在多窗口模式下(默认模式),您将得到两个浏览器窗口。您可以使用以下命令最大化主窗口:

  selenium.windowMaximize(); 

或者使用multiWindow命令行参数禁止使用多重窗口,只使用一个窗口 - 请注意,这会导致某些网站出现问题,特别是当他们试图打破框架。


Every time I launch a Firefox instance via Selenium RC I get 3 windows that I don't need appearing:

  • the add-ons windows notifying me that "3 new add-ons have been installed" (since I'm using a custom profile for Selenium to which it evidently adds the DocumentReadyState, KillFF, and Selenium RC Runner add-ons)

  • the http://localhost:4444/selenium-server/core/Blank.html?start=true window

  • the dual window with two tabs starting with chrome://src/content/RemoteRunner.html?sessionId=... each

I don't need any of these to be visible, and each time I have to manually close the add-ons window, to minimize the two other windows, and to maximize the main browser windows which Selenium controls. After going through this too many times, I got annoyed enough to seek a solution:

Is there any way to automate closing the add-ons window and minimizing the two other windows?

By the way, I'm on OS X so I'd also appreciate some alternative solution which automates this via the OS instead of directly using Selenium.

解决方案

There's a few preferences you can change in your custom profile to prevent the addons window and the additional tab on startup:

  1. Set the extensions.lastAppVersion preference to the version of Firefox that you have installed.
  2. Set the extensions.newAddons preference to false.
  3. Set the extensions.update.notifyUser preference to false.

There might be some more, perhaps others can provide their suggestions in comments or their own answers.

As long as Selenium is running in multi window mode (the default mode) you'll get two browser windows. You could either maximize the main window using the following command:

selenium.windowMaximize();

Or use the multiWindow command line parameter to disable the use of multuple windows and just use a single window - note that this causes issues on some websites, especially if they attempt to break out of frames.

这篇关于如何使用Selenium RC关闭或最小化浏览器窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆