maven
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-remote-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>2.53.1</version>
</dependency>
--------------------------------------------------------------------------------
实例:
public static void main(String[] args) {
/*
//IE
//注意调整IE的保护模式,4种都保持一致
//缩放调至100%
System.setProperty("webdriver.ie.driver", "src/main/java/com/ylfs/IEDriverServer.exe");
DesiredCapabilities capabilities = new DesiredCapabilities();
//忽略安全模式
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING,true);
InternetExplorerDriver driver = new InternetExplorerDriver(capabilities);
*/
//谷歌浏览器
System.setProperty("webdriver.chrome.driver", "src/main/java/com/ylfs/chromedriver.exe");
ChromeDriver driver = new ChromeDriver();
}
selenium各版本下载地址
http://selenium-release.storage.googleapis.com/index.html
ChromeDriver各版本下载地址
http://chromedriver.storage.googleapis.com/index.html
Chrome各版本下载地址
https://www.chromedownloads.net/
关于ChromeDriver支持Chrome版本,在驱动下载地址里的notes.txt有详细的描述。本人就比较新的几个谷歌版本稍微拿出来整理了一下,如下。
ChromeDriver支持Chrome版本
ChromeDriver版本 Chrome版本
ChromeDriver v2.42 Chrome v68-70
ChromeDriver v2.41 Chrome v67-69
ChromeDriver v2.40 Chrome v66-68
ChromeDriver v2.39 Chrome v66-68
ChromeDriver v2.38 Chrome v65-67
ChromeDriver v2.37 Chrome v64-66
ChromeDriver v2.36 Chrome v63-65
ChromeDriver v2.35 Chrome v62-64
ChromeDriver v2.34 Chrome v61-63
ChromeDriver v2.33 Chrome v60-62
ChromeDriver v2.32 Chrome v59-61
ChromeDriver v2.31 Chrome v58-60
ChromeDriver v2.30 Chrome v58-60
ChromeDriver v2.29 Chrome v56-58
ChromeDriver v2.28 Chrome v55-57
ChromeDriver v2.27 Chrome v54-56
ChromeDriver v2.26 Chrome v53-55
ChromeDriver v2.25 Chrome v53-55
ChromeDriver v2.24 Chrome v52-54
ChromeDriver v2.23 Chrome v51-53
ChromeDriver v2.22 Chrome v49-52
ChromeDriver v2.21 Chrome v46-50
ChromeDriver v2.20 Chrome v43-48
ChromeDriver v2.19 Chrome v43-47
ChromeDriver v2.18 Chrome v43-46