java.net.UnknownHostException无法解决硒

时间:2019-02-13 14:07:10

标签: selenium selenium-webdriver apache-poi webdrivermanager-java

直到昨天,我一直在使用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] 

2 个答案:

答案 0 :(得分:0)

我昨天有同样的问题。这是因为有许多Chrome会话在后台运行。

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

然后我重新启动chrome,结果就解决了

答案 1 :(得分:0)

我遇到了类似的问题。我使用 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)