等待驱动程序服务器启动错误执行 Java 测试时超时 CI
Timed out waiting for driver server to start error executing Java tests with Circle CI
我才开始将 Circle CI 工具用于 运行 我的 Java 自动测试(Selenium、Maven)。
我的代码在Java:
public void setUp() {
WebDriverManager.chromedriver().setup();
webDriver = new ChromeDriver(setOptions());
webDriver.manage().window().maximize();
webDriver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
webDriver. manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
public ChromeOptions setOptions() {
ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
options.addArguments("enable-automation");
options.addArguments("--headless");
options.addArguments("window-size=1024,768");
options.addArguments("--disable-extensions");
options.addArguments("--dns-prefetch-disable");
options.addArguments("--disable-gpu");
return options;
}
我的config.yml在.circleci目录:
version: 2.1
jobs:
build:
docker:
- image: cimg/node:16.13.1-browsers
steps:
- checkout
- run: mkdir test-reports
- run:
name: Download Selenium
command: curl -O http://selenium-release.storage.googleapis.com/3.5/selenium-server-standalone-3.5.3.jar
- run:
name: Start Selenium
command: java -jar selenium-server-standalone-3.5.3.jar -log test-reports/selenium.log
background: true
test:
docker:
- image: cimg/openjdk:11.0
steps:
- checkout
- run:
name: build
command: mvn -B -DskipTests clean package
# Then run your tests!
- run:
name: test
command: mvn test -Dtest=SignUp
- store_test_results:
path: target/surefire-reports
workflows:
sample:
jobs:
- build
- test
Build 作业已成功完成。但是 test 作业失败并出现下一个错误:
org.openqa.selenium.WebDriverException:
Timed out waiting for driver server to start.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'df35181eab7e', ip: '172.31.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.13.0-1017-aws', java.version: '11.0.13'
Driver info: driver.version: ChromeDriver
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:24652/status] to be available after 20001 ms
Caused by: java.util.concurrent.TimeoutException
请问如何解决这个问题?
这个错误信息...
org.openqa.selenium.WebDriverException:
Timed out waiting for driver server to start.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'df35181eab7e', ip: '172.31.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.13.0-1017-aws', java.version: '11.0.13'
Driver info: driver.version: ChromeDriver
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:24652/status] to be available after 20001 ms
Caused by: java.util.concurrent.TimeoutException
...表示驱动程序服务器未启动。
您需要注意以下几点:
config.yml
文件在.circleci
目录提到 Selenium v3.5.3:
- run:
name: Download Selenium
command: curl -O http://selenium-release.storage.googleapis.com/3.5/selenium-server-standalone-3.5.3.jar
和
- run:
name: Start Selenium
command: java -jar selenium-server-standalone-3.5.3.jar -log test-reports/selenium.log
其中错误堆栈跟踪提到 Selenium v3.141.59:
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
您需要交叉检查 Circle CI 配置中的 设置并解决问题。
我才开始将 Circle CI 工具用于 运行 我的 Java 自动测试(Selenium、Maven)。
我的代码在Java:
public void setUp() {
WebDriverManager.chromedriver().setup();
webDriver = new ChromeDriver(setOptions());
webDriver.manage().window().maximize();
webDriver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
webDriver. manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
public ChromeOptions setOptions() {
ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
options.addArguments("enable-automation");
options.addArguments("--headless");
options.addArguments("window-size=1024,768");
options.addArguments("--disable-extensions");
options.addArguments("--dns-prefetch-disable");
options.addArguments("--disable-gpu");
return options;
}
我的config.yml在.circleci目录:
version: 2.1
jobs:
build:
docker:
- image: cimg/node:16.13.1-browsers
steps:
- checkout
- run: mkdir test-reports
- run:
name: Download Selenium
command: curl -O http://selenium-release.storage.googleapis.com/3.5/selenium-server-standalone-3.5.3.jar
- run:
name: Start Selenium
command: java -jar selenium-server-standalone-3.5.3.jar -log test-reports/selenium.log
background: true
test:
docker:
- image: cimg/openjdk:11.0
steps:
- checkout
- run:
name: build
command: mvn -B -DskipTests clean package
# Then run your tests!
- run:
name: test
command: mvn test -Dtest=SignUp
- store_test_results:
path: target/surefire-reports
workflows:
sample:
jobs:
- build
- test
Build 作业已成功完成。但是 test 作业失败并出现下一个错误:
org.openqa.selenium.WebDriverException:
Timed out waiting for driver server to start.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'df35181eab7e', ip: '172.31.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.13.0-1017-aws', java.version: '11.0.13'
Driver info: driver.version: ChromeDriver
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:24652/status] to be available after 20001 ms
Caused by: java.util.concurrent.TimeoutException
请问如何解决这个问题?
这个错误信息...
org.openqa.selenium.WebDriverException:
Timed out waiting for driver server to start.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'df35181eab7e', ip: '172.31.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.13.0-1017-aws', java.version: '11.0.13'
Driver info: driver.version: ChromeDriver
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:24652/status] to be available after 20001 ms
Caused by: java.util.concurrent.TimeoutException
...表示驱动程序服务器未启动。
您需要注意以下几点:
config.yml
文件在.circleci
目录提到 Selenium v3.5.3:- run: name: Download Selenium command: curl -O http://selenium-release.storage.googleapis.com/3.5/selenium-server-standalone-3.5.3.jar
和
- run: name: Start Selenium command: java -jar selenium-server-standalone-3.5.3.jar -log test-reports/selenium.log
其中错误堆栈跟踪提到 Selenium v3.141.59:
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
您需要交叉检查 Circle CI 配置中的