gpt4 book ai didi

java - Selenium ChromeDriver 返回未知错误 : unable to discover open pages

转载 作者:行者123 更新时间:2023-11-30 02:52:32 25 4
gpt4 key购买 nike

我创建了一个maven项目,里面的测试包添加了一个testNg测试用例:

public class SampleTestNGTest {    
private WebDriver driver;
@Test
public void testEasy() {
System.setProperty("webdriver.chrome.driver","D:\\NetBeansProjects\\webdrivertestng\\Drivers\\chromedriver.exe");
driver = new ChromeDriver();
driver.get("example.com");
String title = driver.getTitle();
Assert.assertTrue(title.contains("abcd"));
//System.out.println("checking new build");
}

@AfterTest
public void afterTest() {
driver.quit();
}
}

我在Netbeans中完美地执行了它,没有任何错误。但是当我从Jenkins执行时(将maven项目与Jenkins集成),它显示以下错误:

Running SampleTestNGTest
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@6d8acf
Starting ChromeDriver 2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf) on port 2916
Only local connections are allowed.
Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 64.572 sec <<< FAILURE!
testEasy(SampleTestNGTest) Time elapsed: 63.571 sec <<< FAILURE!
org.openqa.selenium.WebDriverException: unknown error: unable to discover open pages
(Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Windows NT 6.1 SP1 x86) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61.32 seconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'MVSL1742', ip: '172.16.17.42', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_05'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)
at SampleTestNGTest.testEasy(SampleTestNGTest.java:24)

afterTest(SampleTestNGTest) Time elapsed: 63.573 sec <<< FAILURE!
java.lang.NullPointerException
at SampleTestNGTest.afterTest(SampleTestNGTest.java:37)


Results :

Failed tests: testEasy(SampleTestNGTest): unknown error: unable to discover open pages(..)
afterTest(SampleTestNGTest)

Tests run: 2, Failures: 2, Errors: 0, Skipped: 0
  1. 如果我使用 FirefoxDriver,构建执行时不会出现错误。

  2. 如果我使用 ChromeDriver,构建执行时会出错。

pom.xml

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>2.53.0</version>
</dependency>

编辑:在我的本地计算机上,ChromeDriver 版本是 2.9

最佳答案

您似乎使用的是非常旧版本的 ChromeDriver。

从您的错误日志来看,它似乎是:2.14,而最新版本是 2.9!

here下载更新版本然后再试一次。另请确保您没有使用最新的 Chrome 浏览器版本,因为 Selenium 支持始终滞后。例如,目前最新的ChromeDriver 2.9仅支持Chrome浏览器版本31-34。可以看到here .

关于java - Selenium ChromeDriver 返回未知错误 : unable to discover open pages,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38195601/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com