Setting up selenium grid to use Microsoft edge

前端 未结 2 2030
深忆病人
深忆病人 2021-01-27 04:43

Environment:

  • win10 (build 10240)
  • Vaadin Testbench 4.1
  • Selenium 2.53
  • Drivers for Firefox, Chrome, IE11 and Edge for bui
2条回答
  •  遥遥无期
    2021-01-27 05:06

    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

提交回复
热议问题