(存坑状态,在加载Chrome中存在一些问题。转使用Firefox,后期回头填坑)
实例背景:
系统:win7
IDE: IntelliJ IDEA
JDK: 8
MAVEN:
1.WebDriver依赖的Jar包
selenium-Java-2.46.0.jar(目前看来,只需要这一个架包就可以实现对浏览器的操作)
2.启动Chrome
System.setProperty("webdriver.chrome.driver", "src\\main\\resources\\chromedriver.exe");(如何查看安装文件的路劲)
WebDriver driver = new ChromeDriver();
driver.get("http://www.baidu.com");
error:
Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting for ChromeDriver server to start.
Build info: version: '2.8.0', revision: '14056', time: '2011-10-06 15:53:48'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_04'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.chrome.ChromeDriverService.start(ChromeDriverService.java:147)
at org.openqa.selenium.chrome.ChromeCommandExecutor.execute(ChromeCommandExecutor.java:46)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:395)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:113)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:74)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:120)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:87)
at WebDriverUtils.Test.main(Test.java:21)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:31024/status, http://localhost:31024/healthz] to be available after 20003 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:86)
at org.openqa.selenium.chrome.ChromeDriverService.start(ChromeDriverService.java:145)
... 7 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:61)
... 8 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:258)
at java.util.concurrent.FutureTask.get(FutureTask.java:119)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
... 9 more
3.