【问题标题】:Windows Edge webdriver fails with WebDriverException: Message: Unknown errorWindows Edge webdriver 失败并出现 WebDriverException:消息:未知错误
【发布时间】:2019-12-20 18:16:14
【问题描述】:

我正在尝试在 CircleCI 中的 Windows Edge 上运行 behave 测试,但即使是简单的测试也无法使用

初始化会话
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

设置

我使用标准的 CircleCI 窗口图像windows-server-2019-vs2019:stable

在那里安装 Edge 驱动程序并尝试将其作为服务启动:

choco install -y jdk10 selenium-edge-driver selenium

然后我ssh到机器调试并尝试

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

这会导致上述错误。 web-driver的路径是正确的,不正确会导致另一个错误。

已经尝试过

  1. 关闭 UAC(使用 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. 尝试使用 Chrome 设置进行连接:

我自己说服务器:

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

这会导致 401 错误错误请求,或者如果我更新 desired_capabilities 类似:

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: No matching capabilities found
  1. 尝试将 Edge 二进制文件更改为 https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ 中的最新版本,但仍然遇到同样的问题。

【问题讨论】:

  • 您是否尝试过停止并重新启动您的服务?
  • 您的 Microsoft Edge 版本和 Microsoft Edge WebDriver 版本是多少?在official docs 上,它说要在Windows 机器上运行作业,您必须将windows 键添加到作业的顶级配置中。 此外,请注意@ 987654324@ 通过 SSH 连接到 Windows 作业并使用 bash shell 会导致终端提示为空。

标签: python selenium microsoft-edge circleci python-behave


【解决方案1】:

目前,无法在 CircleCI 映像上安装 Edge。但是如果像 BrowserStack 这样的服务不适合你,有一种方法可以在你自己的 Windows/Edge 上运行 Selenium/部署官方 Vagrant 映像的 AWS 机器。

  1. 下载official VM with Edge installed(Vagrant 可以)
  2. 如果您打算使用 AWS,请检查 vagrant-aws 在 EC2 上部署映像
  3. 在 Vagrant 镜像上安装 Selenium。你可以尝试使用Puppet,检查this example,但是它使用的是过时的Edge版本,你需要更新the manifest
  4. 花一些时间设置权限/角色和其他 IAM 东西,以便能够从 CircleCI 连接到 EC2。
  5. 现在使用 webdriver.Remote,您可以连接到装有 Edge 和 Web 驱动程序的 Selenium(集线器或独立)。

【讨论】:

    猜你喜欢
    • 2017-06-17
    • 2015-02-21
    • 2020-03-04
    • 2015-08-02
    • 1970-01-01
    • 1970-01-01
    • 2021-07-31
    • 2017-01-05
    • 2018-02-07
    相关资源
    最近更新 更多