-1

我正在使用 Selenide 5.3.1 版。open("https://www.google.com")我使用Selenide 的方法创建了一个示例项目来打开浏览器。这工作正常,它使用 webDriverManager 自动下载了最新的 chrome 驱动程序二进制文件。

现在,如果我尝试在另一台机器上运行相同的示例项目,则会出现以下错误。有人可以帮助理解我为什么会遇到这个问题吗?我不想使用添加 webdriver 路径System.setproperties("key","value")

C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\bin\java.exe -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Users\jaahmed\AppData\Local\JetBrains\IntelliJ IDEA 2019.2\lib\idea_rt.jar=63959:C:\Users\jaahmed\AppData\Local\JetBrains\IntelliJ IDEA 2019.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\jaahmed\AppData\Local\JetBrains\IntelliJ IDEA 2019.2\lib\idea_rt.jar;C:\Users\jaahmed\AppData\Local\JetBrains\IntelliJ IDEA 2019.2\plugins\testng\lib\testng-plugin.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\charsets.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\deploy.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\ext\access-bridge-64.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\ext\cldrdata.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\ext\dnsns.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\ext\jaccess.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\ext\jfxrt.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\ext\localedata.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\ext\nashorn.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\ext\sunec.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\ext\sunjce_provider.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\ext\sunmscapi.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\ext\sunpkcs11.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\ext\zipfs.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\javaws.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\jce.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\jfr.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\jfxswt.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\jsse.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\management-agent.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\plugin.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\resources.jar;C:\New_Software\installedSoftwares\Java\jdk1.8.0_241\jre\lib\rt.jar;C:\New_Software\Jenkins\.jenkins\workspace\testdelete\target\test-classes;C:\Users\jaahmed\.m2\repository\com\codeborne\selenide\5.3.1\selenide-5.3.1.jar;C:\Users\jaahmed\.m2\repository\org\seleniumhq\selenium\selenium-java\3.141.59\selenium-java-3.141.59.jar;C:\Users\jaahmed\.m2\repository\org\seleniumhq\selenium\selenium-api\3.141.59\selenium-api-3.141.59.jar;C:\Users\jaahmed\.m2\repository\org\seleniumhq\selenium\selenium-chrome-driver\3.141.59\selenium-chrome-driver-3.141.59.jar;C:\Users\jaahmed\.m2\repository\org\seleniumhq\selenium\selenium-edge-driver\3.141.59\selenium-edge-driver-3.141.59.jar;C:\Users\jaahmed\.m2\repository\org\seleniumhq\selenium\selenium-firefox-driver\3.141.59\selenium-firefox-driver-3.141.59.jar;C:\Users\jaahmed\.m2\repository\org\seleniumhq\selenium\selenium-ie-driver\3.141.59\selenium-ie-driver-3.141.59.jar;C:\Users\jaahmed\.m2\repository\org\seleniumhq\selenium\selenium-opera-driver\3.141.59\selenium-opera-driver-3.141.59.jar;C:\Users\jaahmed\.m2\repository\org\seleniumhq\selenium\selenium-remote-driver\3.141.59\selenium-remote-driver-3.141.59.jar;C:\Users\jaahmed\.m2\repository\org\seleniumhq\selenium\selenium-safari-driver\3.141.59\selenium-safari-driver-3.141.59.jar;C:\Users\jaahmed\.m2\repository\org\seleniumhq\selenium\selenium-support\3.141.59\selenium-support-3.141.59.jar;C:\Users\jaahmed\.m2\repository\org\apache\commons\commons-exec\1.3\commons-exec-1.3.jar;C:\Users\jaahmed\.m2\repository\com\google\guava\guava\25.0-jre\guava-25.0-jre.jar;C:\Users\jaahmed\.m2\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;C:\Users\jaahmed\.m2\repository\org\checkerframework\checker-compat-qual\2.0.0\checker-compat-qual-2.0.0.jar;C:\Users\jaahmed\.m2\repository\com\google\errorprone\error_prone_annotations\2.1.3\error_prone_annotations-2.1.3.jar;C:\Users\jaahmed\.m2\repository\com\google\j2objc\j2objc-annotations\1.1\j2objc-annotations-1.1.jar;C:\Users\jaahmed\.m2\repository\org\codehaus\mojo\animal-sniffer-annotations\1.14\animal-sniffer-annotations-1.14.jar;C:\Users\jaahmed\.m2\repository\com\squareup\okhttp3\okhttp\3.11.0\okhttp-3.11.0.jar;C:\Users\jaahmed\.m2\repository\com\squareup\okio\okio\1.14.0\okio-1.14.0.jar;C:\Users\jaahmed\.m2\repository\net\lightbody\bmp\browsermob-core\2.1.5\browsermob-core-2.1.5.jar;C:\Users\jaahmed\.m2\repository\net\lightbody\bmp\littleproxy\1.1.0-beta-bmp-17\littleproxy-1.1.0-beta-bmp-17.jar;C:\Users\jaahmed\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.8.9\jackson-core-2.8.9.jar;C:\Users\jaahmed\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.8.9\jackson-databind-2.8.9.jar;C:\Users\jaahmed\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.8.9\jackson-annotations-2.8.9.jar;C:\Users\jaahmed\.m2\repository\dnsjava\dnsjava\2.1.8\dnsjava-2.1.8.jar;C:\Users\jaahmed\.m2\repository\org\slf4j\jcl-over-slf4j\1.7.25\jcl-over-slf4j-1.7.25.jar;C:\Users\jaahmed\.m2\repository\com\jcraft\jzlib\1.1.3\jzlib-1.1.3.jar;C:\Users\jaahmed\.m2\repository\io\netty\netty-all\4.0.51.Final\netty-all-4.0.51.Final.jar;C:\Users\jaahmed\.m2\repository\org\bouncycastle\bcprov-jdk15on\1.58\bcprov-jdk15on-1.58.jar;C:\Users\jaahmed\.m2\repository\org\bouncycastle\bcpkix-jdk15on\1.58\bcpkix-jdk15on-1.58.jar;C:\Users\jaahmed\.m2\repository\net\lightbody\bmp\mitm\2.1.5\mitm-2.1.5.jar;C:\Users\jaahmed\.m2\repository\org\testng\testng\7.0.0\testng-7.0.0.jar;C:\Users\jaahmed\.m2\repository\com\beust\jcommander\1.72\jcommander-1.72.jar;C:\Users\jaahmed\.m2\repository\org\slf4j\slf4j-log4j12\1.7.5\slf4j-log4j12-1.7.5.jar;C:\Users\jaahmed\.m2\repository\org\slf4j\slf4j-api\1.7.5\slf4j-api-1.7.5.jar;C:\Users\jaahmed\.m2\repository\log4j\log4j\1.2.17\log4j-1.2.17.jar;C:\Users\jaahmed\.m2\repository\io\github\bonigarcia\webdrivermanager\3.8.0\webdrivermanager-3.8.0.jar;C:\Users\jaahmed\.m2\repository\commons-io\commons-io\2.6\commons-io-2.6.jar;C:\Users\jaahmed\.m2\repository\com\google\code\gson\gson\2.8.5\gson-2.8.5.jar;C:\Users\jaahmed\.m2\repository\org\apache\commons\commons-lang3\3.8.1\commons-lang3-3.8.1.jar;C:\Users\jaahmed\.m2\repository\org\apache\httpcomponents\httpclient\4.5.6\httpclient-4.5.6.jar;C:\Users\jaahmed\.m2\repository\org\apache\httpcomponents\httpcore\4.4.10\httpcore-4.4.10.jar;C:\Users\jaahmed\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\jaahmed\.m2\repository\commons-codec\commons-codec\1.10\commons-codec-1.10.jar;C:\Users\jaahmed\.m2\repository\org\rauschig\jarchivelib\1.0.0\jarchivelib-1.0.0.jar;C:\Users\jaahmed\.m2\repository\org\apache\commons\commons-compress\1.18\commons-compress-1.18.jar;C:\Users\jaahmed\.m2\repository\org\jsoup\jsoup\1.11.3\jsoup-1.11.3.jar;C:\Users\jaahmed\AppData\Local\JetBrains\IntelliJ IDEA 2019.2\plugins\testng\lib\jcommander-1.27.jar" org.testng.RemoteTestNGStarter -usedefaultlisteners false -socket63958 @w@C:\New_Software\Temp\idea_working_dirs_testng.tmp -temp C:\New_Software\Temp\idea_testng.tmp
log4j:WARN No appenders could be found for logger (io.github.bonigarcia.wdm.WebDriverManager).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
io.github.bonigarcia.wdm.WebDriverManagerException: java.net.UnknownHostException: npm.taobao.org
    at io.github.bonigarcia.wdm.WebDriverManager.handleException(WebDriverManager.java:774)
    at io.github.bonigarcia.wdm.WebDriverManager.manage(WebDriverManager.java:548)
    at io.github.bonigarcia.wdm.WebDriverManager.handleException(WebDriverManager.java:771)
    at io.github.bonigarcia.wdm.WebDriverManager.manage(WebDriverManager.java:548)
    at io.github.bonigarcia.wdm.WebDriverManager.handleException(WebDriverManager.java:764)
    at io.github.bonigarcia.wdm.WebDriverManager.manage(WebDriverManager.java:548)
    at io.github.bonigarcia.wdm.WebDriverManager.setup(WebDriverManager.java:258)
    at TestMe.testm(TestMe.java:14)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
    at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:584)
    at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:172)
    at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
    at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:804)
    at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
    at java.util.ArrayList.forEach(ArrayList.java:1257)
    at org.testng.TestRunner.privateRun(TestRunner.java:770)
    at org.testng.TestRunner.run(TestRunner.java:591)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
    at org.testng.SuiteRunner.run(SuiteRunner.java:304)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
    at org.testng.TestNG.runSuites(TestNG.java:1032)
    at org.testng.TestNG.run(TestNG.java:1000)
    at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:73)
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
Caused by: java.net.UnknownHostException: npm.taobao.org
    at java.net.InetAddress.getAllByName0(InetAddress.java:1281)
    at java.net.InetAddress.getAllByName(InetAddress.java:1193)
    at java.net.InetAddress.getAllByName(InetAddress.java:1127)
    at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:112)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:394)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
    at io.github.bonigarcia.wdm.HttpClient.execute(HttpClient.java:169)
    at io.github.bonigarcia.wdm.WebDriverManager.getDriversFromMirror(WebDriverManager.java:1041)
    at io.github.bonigarcia.wdm.ChromeDriverManager.getDrivers(ChromeDriverManager.java:82)
    at io.github.bonigarcia.wdm.WebDriverManager.filterCandidateUrls(WebDriverManager.java:790)
    at io.github.bonigarcia.wdm.WebDriverManager.downloadAndExport(WebDriverManager.java:566)
    at io.github.bonigarcia.wdm.WebDriverManager.manage(WebDriverManager.java:545)
    ... 33 more


===============================================
Default Suite
Total tests run: 1, Passes: 0, Failures: 1, Skips: 0
===============================================


Process finished with exit code 0```

以下是我正在尝试的简单测试方法。

@Test
  public void testme() {
   open("https://www.google.com");
}
4

1 回答 1

0

此错误消息...

  io.github.bonigarcia.wdm.WebDriverManagerException: java.net.UnknownHostException: npm.taobao.org

...似乎是连接问题。


根据我在使用 Web 驱动程序管理器执行基本网站启动时遇到错误中的讨论

这通常是主机名解析期间的临时错误,意味着本地服务器没有收到来自权威服务器(api.github.com)的响应)...再次尝试强制使用缓存 java.net.UnknownHostException:这通常是主机名解析期间的临时错误,意味着本地服务器没有收到来自权威服务器(api.github.com)的响应

问题应该出在您的主机或网络中(可能是 DNS)。


解决方案

您需要遵循以下提到的步骤:

  • 尝试强制包括以下行的架构:

    WebDriverManager.chromedriver().setup();
    
  • 如果您使用的是Maven (Gradle),请删除.m2( MAVEN_HOME) 子目录并重建项目。

  • 通过IDE清理项目工作区并仅使用所需的依赖项重建项目。
  • 仅限Windows 操作系统)使用CCleaner工具在执行测试套件之前和之后清除所有操作系统琐事。
  • 仅限 LinuxOS)在执行测试套件之前和之后释放和释放 Ubuntu/Linux Mint 中未使用的/缓存的内存
  • 如果您的基本Web Client版本太旧,请通过Revo Uninstaller卸载它并安装最新的 GA 和已发布版本的Web Client
  • 重新启动系统
  • @Test非 root用户身份执行。
于 2020-01-17T09:35:30.790 回答