Search code examples
pythonseleniummicrosoft-edgecirclecipython-behave

Windows Edge webdriver fails with WebDriverException: Message: Unknown error


I'm trying to run behave tests on Windows Edge in CircleCI, but even simple test fails initializing a session with

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\circleci\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\edge\webdriver.py", line 66, in __init__
    desired_capabilities=capabilities)
  File "C:\Users\circleci\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\circleci\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\circleci\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\circleci\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\errorhandler.py", line 208, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: Unknown error

Setup

I use standard CircleCI windows image windows-server-2019-vs2019:stable

Install there Edge driver and try to start it as a service:

choco install -y jdk10 selenium-edge-driver selenium

Then I ssh to the machine for debugging and try

python -c "from selenium import webdriver; webdriver.Edge()"

This cause the error above. The path to the web-driver is correct, an incorrect causes another error.

Already tried

  1. Turning off UAC (using cmd.exe):
reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f
reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v PromptOnSecureDesktop /t REG_DWORD /d 0 /f
reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f
  1. Trying to connect using Chrome settings:

Stating the server by myself:

/c/tools/selenium/MicrosoftWebDriver.exe
[14:48:13.545] - Listening on http://localhost:17556/
python -c "from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver; from selenium.webdriver.common.desired_capabilities import DesiredCapabilities; from selenium.webdriver.chrome.remote_connection import ChromeRemoteConnection; rwd = RemoteWebDriver(command_executor=ChromeRemoteConnection(remote_server_addr='http://localhost:17556', keep_alive=False))"

This results with a 401 error bad request or if I update desired_capabilities something like:

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: No matching capabilities found
  1. Tried to change the Edge binary to the latest in https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ but still have the same issue.

Solution

  • Currently, there is no way to install Edge on the CircleCI image. But if services like BrowserStack doesn't suit you, there is a way to run Selenium with Windows/Edge on your own/AWS machine deploying an official Vagrant image.

    1. Download official VM with Edge installed (Vagrant will be fine)
    2. If you plan to use AWS check vagrant-aws to deploy the image on EC2
    3. Install Selenium on the Vagrant image. You can try to use Puppet for it, check this example, but it uses an outdated Edge version, you need to update the manifest.
    4. Spend some time on setting permissions/roles and other IAM stuff to be able to connect to the EC2 from CircleCI.
    5. Now using webdriver.Remote you can connect to the Selenium (hub or stand alone) with Edge and a web-driver for it installed.