如何使用 Selenium RC 关闭或最小化浏览器窗口?

发布于 2024-09-09 08:18:01 字数 697 浏览 1 评论 0原文

每次我通过 Selenium RC 启动 Firefox 实例时,都会出现 3 个我不需要出现的窗口:

  • 附加组件窗口通知我 “已安装 3 个新附加组件” (因为我正在使用自定义配置文件 显然添加了硒 DocumentReadyState、KillFF 和 Selenium RC Runner 附加组件)

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

  • 带有两个以 chrome 开头的选项卡的双窗口:/ /src/content/RemoteRunner.html?sessionId=...each

我不需要其中任何一个都是可见的,每次我都必须手动关闭附加窗口,最小化其他两个窗口,并最大化 Selenium 控制的主浏览器窗口。在经历了太多次之后,我很恼火,寻求解决方案:

有什么方法可以自动关闭附加组件窗口并最小化其他两个窗口吗?

顺便说一句,我在 OS X 上,所以我也很欣赏一些替代解决方案,它可以通过操作系统自动执行此操作,而不是直接使用 Selenium。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初心 2024-09-16 08:18:01

您可以在自定义配置文件中更改一些首选项,以防止启动时出现插件窗口和附加选项卡:

  1. extensions.lastAppVersion 首选项设置为您已安装的 Firefox 版本。
  2. extensions.newAddons 首选项设置为 false
  3. extensions.update.notifyUser 首选项设置为 false

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

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

selenium.windowMaximize();

或者使用 multiWindow 命令行参数禁用多个窗口的使用并仅使用单个窗口 - 请注意,这会导致某些网站出现问题,特别是当它们试图突破时帧。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文