How to close or minimize browser windows with Selenium RC?

痴心易碎 提交于 2019-12-05 02:39:32

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3224518/how-to-close-or-minimize-browser-windows-with-selenium-rc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!