【问题标题】:Setting up selenium grid to use Microsoft edge设置 selenium 网格以使用 Microsoft Edge
【发布时间】:2016-11-02 19:15:27
【问题描述】:

环境:

  • win10(内部版本 10240)
  • Vaadin 测试平台 4.1
  • 硒 2.53
  • 用于构建 10240 的 Firefox、Chrome、IE11 和 Edge 驱动程序

节点和集线器

启动 java -jar c:\users\powder\vaadin-testbench-standalone-4.1.0.jar -role hub
启动 java -jar c:\users\powder\vaadin-testbench-standalone-4.1.0.jar -role node -Dwebdriver.edge.driver=c:\users\powder\MicrosoftWebDriver.exe

在java代码中的使用

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName(DesiredCapabilities.edge().getBrowserName());
//DesiredCapabilities capabilities = DesiredCapabilities.edge(); Tried as well
capabilities.setCapability("acceptSslCerts", "true");
setDriver(new RemoteWebDriver(new URL(this.remoteHubUrl), capabilities));
getDriver().get("http://www.google.com");

错误信息

转发新会话时出错,找不到:Capabilities [{acceptSslCerts=true, browserName=MicrosoftEdge}]

Selenium grid console - edge is missing

在其他浏览器上一切正常,但在 Edge 上却不行。任何想法如何解决这个问题?

【问题讨论】:

  • 你解决过这个问题吗?我有同样的问题。

标签: selenium selenium-webdriver vaadin microsoft-edge


【解决方案1】:

这里有两个问题:

首先,如果您查看the default node config,您会注意到默认情况下仅启用了 Firefox、Chrome 和 IE(这就是为什么您需要使用它们只需通过系统属性指定驱动程序位置)。如果您想使用任何其他浏览器,则需要使用自己的 json 配置:

{
  "capabilities": [
    {
      "browserName": "MicrosoftEdge",
      "platform": "WIN10",
      "maxInstances": 1
    },
    {
      "browserName": "firefox",
      "platform": "WIN10",
      "maxInstances": 5
    },
    {
      "browserName": "chrome",
      "platform": "WIN10",
      "maxInstances": 5
    },
    {
      "browserName": "internet explorer",
      "platform": "WIN10",
      "maxInstances": 1
    }
  ],
  "hub": "http://selenium-hub-host:4444"
}

并将其传递给您的命令行:

java "-Dwebdriver.edge.driver=c:\path\to\MicrosoftWebDriver.exe" "-Dwebdriver.gecko.driver=c:\path\to\geckodriver.exe" "-Dwebdriver.chrome.driver=c:\path\to\chromedriver.exe" "-Dwebdriver.ie.driver=c:\path\to\IEDriverServer.exe" -jar "c:\path\to\selenium-server-standalone.jar" -role node -nodeConfig "c:\path\to\the\above.json"

(顺便说一句:您也可以使用多个-capabilities-browser 参数将整个配置放入命令行)

理论上这应该可行。但是在实践中,您经常会遇到第二个问题,即:“有时它随机不起作用”;] 最初一切看起来都很好:您的网格将在控制台上正确报告 Edge 浏览器功能,它会正确委派测试对于包含 Edge 的节点,该节点将正确启动 Edge 浏览器,但是浏览器有时会冻结在带有 e 徽标的初始蓝屏上,几秒钟后,您会在客户端收到一些异常,而没有任何有意义的堆栈跟踪或消息(我现在没有将它保存到任何地方粘贴在这里)。

有人建议workaround 在同一台机器上启动 2 个单独的节点(当然在不同的端口上):一个仅用于 Edge,第二个用于 IE、FF 和 Chrome。这样它似乎工作得相当稳定(在运行 win-10 和 Selenium-3.4.0 的 Edge build 15063 上测试)

其他信息:

除了上述之外,Edge 驱动程序几乎没有限制,需要在配置中使用特定的解决方法:

  • 目前驱动程序/浏览器仅支持 1 个并发会话,因此必须将 maxInstances 设置为 1(感谢 this answer
  • 驱动程序必须在前台运行,这样浏览器窗口才能真正显示在桌面上。因此,该节点不能作为 Windows 服务启动,也不能在启动时从 Windows 任务计划程序启动。自动启动节点的最佳方法是配置自动登录并将启动节点的批处理脚本添加到用户的启动程序中,如my article 中所述

【讨论】:

    【解决方案2】:

    尝试将 -D 参数放在 -jar 参数之前。我有一个问题,它认为 -Dwebdriver..... 是 selenium 本身而不是 java 的参数。

    【讨论】:

    • 没有文档解释预先定义了 -D 变量的小事浪费了很多时间。如果路径包含空格,请确保使用单引号或双引号,并使用绝对路径。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-03
    • 1970-01-01
    • 2023-01-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多