java.net.UnknownHostException 无法在 selenium 中求解

java.net.UnknownHostException Can't Solve in selenium

直到昨天,我一直在使用 Webdriver Manager,它运行得很成功。但今天它扔了一些 UnknownHostException

我的依赖:

<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>3.0.0</version>
    <scope>test</scope>
</dependency>

这是我以前打开浏览器的方式:

WebDriverManager.chromedriver().setup();
             driver = new ChromeDriver();

我找不到 Perfect Solution 但我得到了 some solution 也就是 not clear 你们能帮帮我吗!

我的错误:

[INFO] Running TestSuite
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[ERROR] Tests run: 3, Failures: 1, Errors: 0, Skipped: 2, Time elapsed: 1.382 s <<< FAILURE! - in TestSuite
[ERROR] Start_Browser(Test.LoginTest)  Time elapsed: 1.257 s  <<< FAILURE!
io.github.bonigarcia.wdm.WebDriverManagerException: java.net.UnknownHostException: chromedriver.storage.googleapis.com
    at Test.LoginTest.Start_Browser(LoginTest.java:19)
Caused by: java.net.UnknownHostException: chromedriver.storage.googleapis.com
    at Test.LoginTest.Start_Browser(LoginTest.java:19)

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   LoginTest.Start_Browser:19->Openbrowser.Setupbrowser:18 » WebDriverManager jav...
[INFO] 

我昨天遇到了同样的问题。这是因为后台有很多 chrome 个会话 运行。

删除文件夹并尝试 C:\Users\yourUsername\.m2\repository\webdriver

然后我重新启动 chrome 并且成功了

我有类似的问题。我使用 selenium webdriver 的代码正在运行,突然间它现在不工作了。我收到以下错误。现在不知道如何解决?

23:39:58,881  INFO main                             [Logging] Logger initialized: file:/C:/vivek/dev/automation/ta-cps-roundtrips/target/classes/META-INF/log4j.xml
23:39:58,883  INFO main                             [IntegrationTestSuiteHelper] configroot: src/main/resources
23:40:00,350  INFO main                             [WebDriverManager] Reading https://chromedriver.storage.googleapis.com/ to seek chromedriver
23:40:00,458  INFO main                             [ResolutionCache] Clearing WebDriverManager resolution cache
23:40:00,460  WARN main                             [WebDriverManager] There was an error managing chromedriver 81.0.4044.138 (java.net.UnknownHostException: chromedriver.storage.googleapis.com) ... trying again avoiding reading release from repository
23:40:00,686  WARN main                             [VersionDetector] Error reading version.properties, using local instead
23:40:00,698  INFO main                             [WebDriverManager] Reading https://chromedriver.storage.googleapis.com/ to seek chromedriver
23:40:00,703  WARN main                             [WebDriverManager] There was an error managing chromedriver (latest version) (java.net.UnknownHostException: chromedriver.storage.googleapis.com) ... trying again using latest driver stored in cache
23:40:00,712  INFO main                             [WebDriverManager] Reading https://chromedriver.storage.googleapis.com/ to seek chromedriver
23:40:00,716 ERROR main                             [WebDriverManager] There was an error managing chromedriver (latest version) (java.net.UnknownHostException: chromedriver.storage.googleapis.com)
io.github.bonigarcia.wdm.config.WebDriverManagerException: java.net.UnknownHostException: chromedriver.storage.googleapis.com
    at io.github.bonigarcia.wdm.WebDriverManager.getDriversFromXml(WebDriverManager.java:915)
    at io.github.bonigarcia.wdm.managers.ChromeDriverManager.getDriverUrls(ChromeDriverManager.java:101)
    at io.github.bonigarcia.wdm.WebDriverManager.createUrlHandler(WebDriverManager.java:797)
    at io.github.bonigarcia.wdm.WebDriverManager.download(WebDriverManager.java:649)
    at io.github.bonigarcia.wdm.WebDriverManager.manage(WebDriverManager.java:567)
    at io.github.bonigarcia.wdm.WebDriverManager.fallback(WebDriverManager.java:792)
    at io.github.bonigarcia.wdm.WebDriverManager.handleException(WebDriverManager.java:773)
    at io.github.bonigarcia.wdm.WebDriverManager.manage(WebDriverManager.java:573)
    at io.github.bonigarcia.wdm.WebDriverManager.handleException(WebDriverManager.java:766)
    at io.github.bonigarcia.wdm.WebDriverManager.manage(WebDriverManager.java:573)
    at io.github.bonigarcia.wdm.WebDriverManager.setup(WebDriverManager.java:287)