【发布时间】: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的路径是正确的,不正确会导致另一个错误。
已经尝试过
- 关闭 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
- 尝试使用 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
- 尝试将 Edge 二进制文件更改为 https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ 中的最新版本,但仍然遇到同样的问题。
【问题讨论】:
-
您是否尝试过停止并重新启动您的服务?
-
您的 Microsoft Edge 版本和 Microsoft Edge WebDriver 版本是多少?在official docs 上,它说要在Windows 机器上运行作业,您必须将
windows键添加到作业的顶级配置中。 此外,请注意@ 987654324@ 通过 SSH 连接到 Windows 作业并使用bashshell 会导致终端提示为空。
标签: python selenium microsoft-edge circleci python-behave