![](/img/trans.png)
[英]Exception in thread “main” org.openqa.selenium.WebDriverException: chrome not reachable
[英]Exception in thread “main” org.openqa.selenium.WebDriverException: java.io.IOException: Unable to parse URL: http://localhost:?????/session
我该如何处理以下异常。 我正在使用 selenium v3.141.59 和 geckodriver v0.26 和 firefox v65.0。 对于 chrome,我也遇到了同样的例外情况。
Exception in thread "main" org.openqa.selenium.WebDriverException: java.io.IOException: Unable to parse URL: http://localhost:?????/session
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'HP', ip: '172.29.11.119', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:92)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
at SeleniumDrivers.main(SeleniumDrivers.java:10)
Caused by: java.io.IOException: Unable to parse URL: http://localhost:?????/session
at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:64)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:105)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
看起来您的端口是:?????
您应该指向您的应用程序端口(如果您使用的是自定义端口(不是 80 或 443))
检查您的应用程序端口:
Windows:
CMD -> netstat -a
检查监听端口。
Linux:
终端-> netstat -tlnp
检查监听端口。
默认 web 流量在端口 80(未加密)443(加密)上运行。 您可以通过尝试访问https://duckduckgo.com而不是您的本地主机来对 selenium 进行故障排除。
根据您编写的语言检查文档,并检查基础知识是否有序。 https://www.selenium.dev/documentation/en/
此错误消息...
Exception in thread "main" org.openqa.selenium.WebDriverException: java.io.IOException: Unable to parse URL: http://localhost:?????/session
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'HP', ip: '172.29.11.119', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:92)
.
.
Caused by: java.io.IOException: Unable to parse URL: http://localhost:?????/session
...意味着GeckoDriver无法启动/产生新的浏览上下文,即Firefox 浏览器session。
根据Unable to parse URL: http://localhost:????/session中的讨论,由于计算机语言设置不兼容,会观察到此错误。
可以通过将 localhost 语言设置为Standard English来解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.