Selenium Chrome 浏览器 org.openqa.selenium.WebDriverException:等待驱动程序服务器启动超时 [英] Selenium Chrome Browser org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start
问题描述
公共类 Dem {public static void main(String[] args) 抛出 InterruptedException {WebDriver 驱动程序;String url = "https://www.google.com";System.setProperty("webdriver.chrome.driver","C:\Users\Jim\Downloads\chromedriver_win32\chromedriver.exe");驱动程序 = 新的 ChromeDriver();driver.get(url);驱动程序关闭();}}
Selenium webdriver 和 Chrome 驱动程序是最新版本
硒网络驱动程序:3.14.0
铬驱动程序:2.42
java:1.8.0_181
这是运行代码后的错误.谷歌浏览器根本无法启动.
<块引用>严重:org.apache.commons.exec.ExecuteException:进程退出并出现错误:-1073741792(退出值:-1073741792)异常线程主"org.openqa.selenium.WebDriverException:超时等待驱动程序服务器启动. 构建信息:版本:'3.14.0',修订版:'aacccce0',时间:'2018-08-02T20:13:22.693Z' 驱动程序信息:driver.version: ChromeDriver 在org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:193)在org.openqa.selenium.remote.service.DriverService.start(DriverService.java:179)在org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)在org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212)在org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:130)在org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:181)在org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:168)在org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123)在 news.Dem.main(Dem.java:17) 引起的:org.openqa.selenium.net.UrlChecker$TimeoutException:超时等待[
如果您没有收到以上消息并且您的服务器没有启动,请检查您收到的错误是什么并相应地做出响应?可能下载了损坏的二进制文件,重新下载.
2.无法访问主机名为 localhost
如果您能够按照上述步骤成功启动 chromedriver,现在尝试使用相应端口访问以下 url.http://localhost:{port}/status
例如,在上面的消息中,服务器在端口 9515 上启动.在浏览器中访问 url,http://localhost:9515/status
你应该得到上面的消息,表明可以使用主机名访问服务器 localhost
如果您无法访问,请使用管理员权限在编辑器中打开 C:WindowsSystem32driversetchosts 并检查 localhost
DNS 已映射到 127.0.0.1代码>
public class Dem {
public static void main(String[] args) throws InterruptedException {
WebDriver driver;
String url = "https://www.google.com";
System.setProperty("webdriver.chrome.driver","C:\Users\Jim\Downloads\chromedriver_win32\chromedriver.exe");
driver = new ChromeDriver();
driver.get(url);
driver.close();
}
}
Selenium webdriver and Chrome driver are the latest versions
Selenium webdriver :3.14.0
chromedriver: 2.42
java:1.8.0_181
And this is the error after running the code. Google chrome doesn't launch at all.
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: -1073741792 (Exit value: -1073741792) Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start. Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:13:22.693Z' Driver info: driver.version: ChromeDriver at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:193) at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:179) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:130) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:181) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:168) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123) at news.Dem.main(Dem.java:17) Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:32986/status] to be available after 20002 ms at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100) at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:188) ... 9 more
Debugging Steps
It may be either of the two below issue.
1. Chrome Driver not started for some reason:
Run the chrome driver in terminal maually
C:UsersJim> C:UsersJimDownloadschromedriver_win32chromedriver.exe
Now we have to get the following message denoting server started sucessfully.
If you are not getting above message and your server is not started, then check what is error you are getting and respond accorsingly? May downloaded corrupted binary, the download it again.
2. Unable to access the chrome driver with hostname as localhost
If you able to start chromedriver sucessfully as in above steps, now try to access the below url with respective port.
http://localhost:{port}/status
For e.g., in above message, the server started on port 9515. Access the url in browser, http://localhost:9515/status
You should get above message indicating server is accessible with hostname as localhost
If your are not able access, then open C:WindowsSystem32driversetchosts in editor with administrator privilege and check localhost
DNS is mapped to 127.0.0.1
这篇关于Selenium Chrome 浏览器 org.openqa.selenium.WebDriverException:等待驱动程序服务器启动超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!