chrome driver下载地址:https://npm.taobao.org/mirrors/chromedriver
driver与chrome的对应关系:
- 1.进入最新的driver,查看notes.txt文件,即可获取到对应关系
- 2.使用curl命令获取对应关系
curl https://npm.taobao.org/mirrors/chromedriver/2.40/notes.txt grep -e "ChromeDriver v" -e "chrome v" |grep -v "Resolved" > chrome.txt
- 3.部分版本driver对应关系
ChromeDriver v2.40 (2018-06-07) | Chrome v66-68 |
ChromeDriver v2.39 (2018-05-30) | Chrome v66-68 |
ChromeDriver v2.38 (2018-04-17) | Chrome v65-67 |
ChromeDriver v2.37 (2018-03-16) | Chrome v64-66 |
ChromeDriver v2.36 (2018-03-02) | Chrome v63-65 |
ChromeDriver v2.35 (2018-01-10) | Chrome v62-64 |
ChromeDriver v2.34 (2017-12-10) | Chrome v61-63 |
ChromeDriver v2.33 (2017-10-03) | Chrome v60-62 |
ChromeDriver v2.32 (2017-08-30) | Chrome v59-61 |
ChromeDriver v2.31 (2017-07-21) | Chrome v58-60 |
ChromeDriver v2.30 (2017-06-07) | Chrome v58-60 |
ChromeDriver v2.29 (2017-04-04) | Chrome v56-58 |
ChromeDriver v2.28 (2017-03-09) | Chrome v55-57 |
ChromeDriver v2.27 (2016-12-23) | Chrome v54-56 |
ChromeDriver v2.26 (2016-12-09) | Chrome v53-55 |
ChromeDriver v2.25 (2016-10-25) | Chrome v53-55 |
ChromeDriver v2.24 (2016-09-09) | Chrome v52-54 |
ChromeDriver v2.23 (2016-08-04) | Chrome v51-53 |
ChromeDriver v2.22 (2016-06-06) | Chrome v49-52 |
ChromeDriver v2.21 (2016-01-28) | Chrome v46-50 |
ChromeDriver v2.20 (2015-10-08) | Chrome v43-48 |
ChromeDriver v2.19 (2015-08-28) | Chrome v43-47 |
ChromeDriver v2.18 (2015-08-19) | Chrome v43-46 |
- 4.将Chromedriver导入到工程中,便于管理
import org.openqa.selenium.By;import org.openqa.selenium.WebDriver;import org.openqa.selenium.chrome.ChromeDriver;import java.util.concurrent.TimeUnit;public class Baidu { public static void main(String[] args){ String chromepath = System.getProperty("user.dir")+"/src/main/java/drivers/chromedriver"; System.setProperty("webdriver.chrome.driver",chromepath); WebDriver driver = new ChromeDriver(); driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS); driver.get("https://www.baidu.com"); driver.findElement(By.xpath("//input[@class='s_ipt' and @id='kw']")).sendKeys("selenium"); driver.findElement(By.xpath("//input[@id='su']")).click(); System.out.println(driver.findElement(By.xpath("//span[@class='nums_text']")).getText()); driver.quit(); System.out.println(); }}