【发布时间】:2024-01-20 09:07:01
【问题描述】:
开篇
我正在使用 the Microsoft WebDriver server 来自动化 Microsoft Edge。
我在前 2-3 次尝试时能够启动浏览器,但随后的尝试似乎导致 WebDriver 服务器挂起。当我发送新会话命令时:
- WebDriver 服务器记录它收到 /session 请求。
- 任何现有的 Edge 实例都被服务器强制终止。
- 新的 Edge 窗口打开(到新标签页)。
- 没有其他事情发生。 WebDriver 服务器从不发送响应。
Edge 目前完全可用。我可以手动将其导航到页面,否则它看起来功能齐全。
另一方面,当新会话请求处于挂起状态时,WebDriver 服务器不会响应其他请求。例如,curl http://192.168.20.248:4444/status 只会挂起,服务器也不会记录任何传入请求。 (不过,我猜这可能是有意的行为?)
如果我手动关闭 Edge,那么 WebDriver 服务器会发送响应:{"sessionId":null,"status":13,"value":{"message":"unknown error"}}
有什么想法可能会出错吗?我可以收集任何日志或其他诊断信息来帮助调试吗?
详情
我正在运行 Edge build 10240(和 Windows 10 build 10240,即公开发行版)。我已经在虚拟机和物理机上重现了这一点。
在 Windows 10 机器上,我在具有管理权限的命令提示符中运行 WebDriver 服务器:
"C:\Program Files (x86)\Microsoft Web Driver\MicrosoftWebDriver.exe" --port=4444 --host=192.168.20.248
在单独的 Linux 机器上,我正在运行此客户端代码。它在到达.get 呼叫之前挂起。
import logging
import time
from selenium import webdriver
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
try:
driver = webdriver.Remote(
command_executor='http://192.168.20.248:4444',
desired_capabilities=DesiredCapabilities.CHROME)
driver.get('http://www.example.com')
driver.get('http://www.google.com')
driver.quit()
except WebDriverException as e:
logging.warning('caught error: %s' % e)
我也可以仅使用原始线路协议来重现该行为,无论其价值如何。对/session 的卷曲永远不会结束。
#!/bin/bash
wd_remote="http://192.168.20.248:4444"
echo "STATUS: $(curl -s ${wd_remote}/status)"
resp=$(curl -sd '{"desiredCapabilities": {"browserName":"MicrosoftEdge"}}' "${wd_remote}/session")
session_id=$(echo "${resp}" | sed -rn 's/.*"sessionId":"([^"]+).*/\1/ p')
if [[ -z "${session_id}" ]]; then
echo "error starting session: ${resp}"
exit 1
fi
echo "started session ${session_id}"
curl -s -d '{"url": "http://www.google.com"}' "${wd_remote}/session/${session_id}/url"
curl -s -XDELETE "${wd_remote}/session/${session_id}"
echo "quit session ${session_id}"
更新 (wilx)
几分钟后我可以看到 EdgeWebDriver 的响应,表明超时:
2016-01-20 11:38:19 DEBUG org.apache.http.wire:72 - http-outgoing-3 << "HTTP/1.1 200 OK[\r][\n]"
2016-01-20 11:38:19 DEBUG org.apache.http.wire:72 - http-outgoing-3 << "Content-Type: application/json;charset=UTF-8[\r][\n]"
2016-01-20 11:38:19 DEBUG org.apache.http.wire:72 - http-outgoing-3 << "Server: Microsoft-HTTPAPI/2.0[\r][\n]"
2016-01-20 11:38:19 DEBUG org.apache.http.wire:72 - http-outgoing-3 << "Access-Control-Allow-Origin: *[\r][\n]"
2016-01-20 11:38:19 DEBUG org.apache.http.wire:72 - http-outgoing-3 << "Date: Wed, 20 Jan 2016 10:38:19 GMT[\r][\n]"
2016-01-20 11:38:19 DEBUG org.apache.http.wire:72 - http-outgoing-3 << "Content-Length: 60[\r][\n]"
2016-01-20 11:38:19 DEBUG org.apache.http.wire:72 - http-outgoing-3 << "[\r][\n]"
2016-01-20 11:38:19 DEBUG org.apache.http.wire:86 - http-outgoing-3 << "{"sessionId":null,"status":21,"value":{"message":"Timeout"}}"
【问题讨论】:
-
+1 在这里。我还尝试了版本WebDriver for Windows Insiders,它似乎更新了几个月。不过,没有骰子。
标签: selenium webdriver microsoft-edge