问题描述
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和Chrome驱动程序是 最新版本
Selenium webdriver and Chrome driver are the latest versions
Selenium webdriver:3.14.0
Selenium webdriver :3.14.0
chromedriver:2.42
chromedriver: 2.42
java:1.8.0_181
java:1.8.0_181
这是运行代码后的错误. Google chrome根本不会启动.
推荐答案
调试步骤
可能是以下两个问题之一.
Debugging Steps
It may be either of the two below issue.
1. Chrome驱动程序由于某种原因无法启动:
手动在终端中运行chrome驱动程序
Run the chrome driver in terminal maually
C:\ Users \ Jim> C:\Users\Jim\Downloads\chromedriver_win32\chromedriver.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.无法访问主机名为localhost
2. Unable to access the chrome driver with hostname as localhost
如果您能够按照上述步骤成功启动chromedriver,现在尝试使用相应的端口访问以下网址.http://localhost:{port}/status
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
例如,在上述消息中,服务器在端口9515上启动.在浏览器http://localhost:9515/status
For e.g., in above message, the server started on port 9515. Access the url in browser, http://localhost:9515/status
您应该获得以上消息,指示服务器可以使用主机名localhost
You should get above message indicating server is accessible with hostname as localhost
如果您无法访问,请使用管理员权限在编辑器中打开C:\ Windows \ System32 \ drivers \ etc \ hosts并检查localhost
DNS是否已映射到127.0.0.1
If your are not able access, then open C:\Windows\System32\drivers\etc\hosts in editor with administrator privilege and check localhost
DNS is mapped to 127.0.0.1
这篇关于Selenium Chrome浏览器org.openqa.selenium.WebDriverException:等待驱动程序服务器启动时超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!