selenium打开chrome出错

在使用selenium启动谷歌Chrome浏览器的时候,是需要用到chromedirver的,两者之间的版本是需要匹配的,否则会出现下面类似的报错:

 

Driver info: driver.version: ChromeDriver
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:192) ~[selenium-remote-driver-3.11.0.jar:?]
    at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:178) ~[selenium-remote-driver-3.11.0.jar:?]
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79) ~[selenium-remote-driver-3.11.0.jar:?]
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545) ~[selenium-remote-driver-3.11.0.jar:?]
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:209) ~[selenium-remote-driver-3.11.0.jar:?]
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:132) ~[selenium-remote-driver-3.11.0.jar:?]
    at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:181) ~[selenium-chrome-driver-3.11.0.jar:?]
    at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:168) ~[selenium-chrome-driver-3.11.0.jar:?]
    at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:157) ~[selenium-chrome-driver-3.11.0.jar:?]
    at cn.enn.bigdata.webpig.webdriver.ChromeDriverFactory.create(ChromeDriverFactory.java:40) ~[classes/:?]
    at cn.enn.bigdata.webpig.webdriver.WebDriverFactory.produce(WebDriverFactory.java:24) ~[classes/:?]
    at cn.enn.bigdata.webpig.webdriver.WebDriverWrapper.reset(WebDriverWrapper.java:64) ~[classes/:?]
    at cn.enn.bigdata.webpig.webdriver.WebDriverWrapper.(WebDriverWrapper.java:56) ~[classes/:?]
    at cn.enn.bigdata.webpig.webdriver.WebDriverWrapper.(WebDriverWrapper.java:48) ~[classes/:?]
    at cn.enn.bigdata.webpig.crawler.Pigs$CrawlerThread.run(Pigs.java:122) [classes/:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_101]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_101]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_101]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_101]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_101]
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:18308/status] to be available after 20002 ms
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100) ~[selenium-remote-driver-3.11.0.jar:?]
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:187) ~[selenium-remote-driver-3.11.0.jar:?]
    ... 19 more
Caused by: java.util.concurrent.TimeoutException
    at java.util.concurrent.FutureTask.get(FutureTask.java:205) ~[?:1.8.0_101]
    at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:148) ~[guava-23.6-jre.jar:?]
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75) ~[selenium-remote-driver-3.11.0.jar:?]
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:187) ~[selenium-remote-driver-3.11.0.jar:?]
    ... 19 more

我用的是62版本,chromedriver用的是2.33的版本

chromedriver版本 支持的Chrome版本
v2.41 v67-69
v2.40 v66-68
v2.39 v66-68
v2.38 v65-67
v2.37 v64-66
v2.36 v63-65
v2.35 v62-64
v2.34 v61-63
v2.33 v60-62
v2.32 v59-61
v2.31 v58-60
v2.30 v58-60
v2.29 v56-58
v2.28 v55-57
v2.27 v54-56
v2.26 v53-55
v2.25 v53-55
v2.24 v52-54
v2.23 v51-53
v2.22 v49-52
v2.21 v46-50
v2.20 v43-48
v2.19 v43-47
v2.18 v43-46
v2.17 v42-43
v2.13 v42-45
v2.15 v40-43
v2.14 v39-42
v2.13 v38-41
v2.12 v36-40
v2.11 v36-40
v2.10 v33-36
v2.9 v31-34
v2.8 v30-33
v2.7 v30-33
v2.6 v29-32
v2.5 v29-32
v2.4 v29-32

下面是谷歌浏览器与chromedriver的版本对应关系,供参考

驱动的下载地址如下: 
http://chromedriver.storage.googleapis.com/index.html

或者

http://npm.taobao.org/mirrors/chromedriver/

你可能感兴趣的:(技术运维)