<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>[3.0.1,)</version>//获取最新的版本库
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.8.2</version>
<type>jar</type>
</dependency>
代码:
public static void getIndex2() {
//之前运行程序发现生成了N多个chrome driver进程,搞不懂为什么会有那么多进程产生,网上查了下,说起这个service有用,拿来试下,效果未知
ChromeDriverService service = new
ChromeDriverService.Builder().usingDriverExecutable(new
File("./driver/chromedriver.exe")).usingAnyFreePort().build()
try {
service.start()
} catch (IOException ex) {
Logger.getLogger(kechengbiaoIndex.class.getName()).log(Level.SEVERE, null, ex)
}
//end
//正式开始
//先定义浏览器驱动,我用chrome浏览器,网上下载一个chromedriver.exe,启动时需要加载
System.getProperties().setProperty("webdriver.chrome.driver", "./driver/chromedriver.exe")
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)