简体   繁体   中英

Setting up selenium grid to use Microsoft edge

Environment:

  • win10 (build 10240)
  • Vaadin Testbench 4.1
  • Selenium 2.53
  • Drivers for Firefox, Chrome, IE11 and Edge for build 10240

Node and hub

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

Usage in java code

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");

Errormessage

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

Selenium grid console - edge is missing

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

There are 2 problems here:

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"

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

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).

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)

Additional info:

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

  • 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

Try putting the -D parameters before the -jar parameter. I had an issue where it thought -Dwebdriver..... was a parameter to selenium itself instead of java.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM