【问题标题】:Exception in thread "main" org.openqa.selenium.WebDriverException: java.io.IOException: Unable to parse URL: http://localhost:?????/session线程“主”org.openqa.selenium.WebDriverException 中的异常:java.io.IOException:无法解析 URL:http://localhost:?????/session
【发布时间】:2020-06-30 07:53:35
【问题描述】:

如何处理以下异常。我正在使用 selenium v​​3.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)

【问题讨论】:

标签: java selenium selenium-webdriver webdriver ioexception


【解决方案1】:

看起来你的端口是:?????

您应该指向您的应用程序端口(如果您使用的是自定义端口(不是 80 或 443))

检查你的应用程序端口:

Windows:

CMD -> netstat -a

检查监听端口。

Linux:

终端 -> netstat -tlnp

检查监听端口。

默认网络流量在端口 80(未加密)443(加密)上运行。 您可以尝试访问 https://duckduckgo.com 而不是您的本地主机来解决 selenium。

根据您编写的语言检查文档,并检查基础知识是否有序。 https://www.selenium.dev/documentation/en/

【讨论】:

    【解决方案2】:

    此错误消息...

    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 浏览器 会话。

    根据Unable to parse URL: http://localhost:????/session 中的讨论,由于计算机语言设置不兼容而观察到此错误。


    解决方案

    可以通过将本地主机语言设置为标准英语来解决此问题。

    【讨论】:

      猜你喜欢
      • 2018-12-31
      • 2017-10-30
      • 1970-01-01
      • 2014-10-25
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多