设置硒网格以使用Microsoft Edge [英] Setting up selenium grid to use Microsoft edge

查看:177
本文介绍了设置硒网格以使用Microsoft Edge的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境:

  • win10(内部版本10240)
  • Vaadin Testbench 4.1
  • 硒2.53
  • 用于Build 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节点-Dwebdriver.edge.driver = c:\ users \ powder \ MicrosoftWebDriver.exe

start java -jar c:\users\powder\vaadin-testbench-standalone-4.1.0.jar -role hub
start 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");

错误消息

转发新会话时出错:功能[{acceptSslCerts = true,browserName = MicrosoftEdge}]

Error forwarding the new session cannot find : Capabilities [{acceptSslCerts=true, browserName=MicrosoftEdge}]

硒网格控制台-缺少边缘

其他所有浏览器都可以正常运行,但Edge不能正常运行.有任何解决办法的想法吗?

Everything is working fine with other browsers, but not with Edge. Any ideas how to fix that?

推荐答案

这里有2个问题:

首先,如果您查看默认节点配置,您会注意到默认情况下仅启用Firefox,Chrome和IE(这就是为什么您只需要通过系统属性指定驱动程序位置的原因).如果要使用其他浏览器,则需要使用自己的json配置:

First, if you look at the default node config you will notice that only Firefox, Chrome and IE are enabled by default (that's why all you need to use them is specify driver location via a system property). If you want to use any other browser then you need to use your own json config:

{
  "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"
}

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

and pass it to your command line:

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参数将整个配置放在命令行中)

(btw: alternatively you can also put the whole config in your command line using multiple -capabilities or -browser params)

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

This in theory should work. However in practice you will often be hit by the 2nd problem, which is: "sometimes it randomly doesn't work" ;] Initially everything will look fine: your grid will properly report Edge browser capability on the console, it will properly delegate tests to a node containing Edge, the node will properly start Edge browser, however the browser will sometimes freeze on its initial blue screen with e logo and after few seconds you will get some exception on the client side without any meaningful stack-trace nor message (I don't have it saved anywhere to paste here now).

有人建议解决方法,可在同一台计算机上(当然在不同端口上)启动2个单独的节点:一个仅用于Edge,第二个用于IE,FF和Chrome.这样,它似乎就可以稳定运行了(在win-10和Selenium-3.4.0上运行的Edge版本15063上进行了测试)

Some people suggested a workaround to start 2 separate nodes on the same machine (on different ports of course) : one only for Edge and second for IE, FF and Chrome. This way it seems to work pretty stable (tested on Edge build 15063 running on win-10 and Selenium-3.4.0)

其他信息:

除上述内容外,Edge驱动程序具有一些限制,这些限制要求在配置中采取特定的解决方法:

Apart from the above, Edge driver has few limitations that require specific workarounds in the configuration:

  • 当前驱动程序/浏览器仅支持1个并发会话,因此maxInstances必须设置为1(对
  • currently only 1 concurrent session is supported by the driver/browser so maxInstances must be set to 1 (kudos to this answer)
  • the driver must be running in the foreground, so that the browser window can be actually displayed on the desktop. Therefore the node cannot be started as a Windows Service nor from Windows Task Scheduler at startup. The best way to automate starting of the node is to configure auto-login and add a batch script starting the node to user's Startup Programs as described in my article

这篇关于设置硒网格以使用Microsoft Edge的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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