簡體   English   中英

Exception in thread “main” org.openqa.selenium.WebDriverException: java.io.IOException: Unable to parse URL: http://localhost:?????/session

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM