selenium使用谷歌浏览器

时间:2021-02-05 21:05:39

参考:
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

selenium使用谷歌浏览器

安装路径(默认路径):
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

selenium版本:

<!-- selenium -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.41.0</version>
</dependency>

下载chromedriver:
下载地址: https://sites.google.com/a/chromium.org/chromedriver/downloads

代码:

System.setProperty("webdriver.chrome.driver", "D:/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.baidu.com");
driver.close();