Step1: 下载chromedriver。

下载路径: http://chromedriver.storage.googleapis.com/index.html

选择一个合适的下载即可。我下载的是2.20版本的chromedriver_win32.zip ,解压之后得到chromedriver.exe 。

Step2: 放置chromedriver.exe

在跟项目包平行的地方新建一个包,比如”lib",然后将 chromedriver.exe拷贝到lib下。

Step3: 添加 webdriver.chrome.driver 属性设置

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver; public class ChromeTest { public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","src/lib/chromedriver.exe"); WebDriver wd = new ChromeDriver();
wd.get("http://www.baidu.com");
try {
Thread.sleep(1200);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(wd.getCurrentUrl());
wd.quit(); }
}

Step4: 运行

Starting ChromeDriver 2.20.353145 (xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx) on port 14153
Only local connections are allowed.
https://www.baidu.com/

Selenium webdriver Java 操作chrome 浏览器的更多相关文章

  1. Selenium webdriver Java 操作IE浏览器

    V1.0版本:直接新建WebDriver使用 import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetE ...

  2. selenium webdriver python 操作Chrome浏览器

    Step1: 下载chromedriver. 下载路径: http://chromedriver.storage.googleapis.com/index.html 选择一个合适的下载即可.我下载的是 ...

  3. selenium webdriver python 操作IE浏览器

    Step1:下载IEDriverServer 下载路径:http://selenium-release.storage.googleapis.com/index.html 我下载的是2.48版本的IE ...

  4. [selenium webdriver Java]常用api

    1. 获取元素文本 WebElement类的getText()方法返回元素的innerText属性.所以元素里如果有子节点一样也会被返回出来.如下所示 public class GetText { @ ...

  5. atitit.浏览器web gui操作类库 和 操作chrome浏览器的类库使用总结

    atitit.浏览器web gui操作类库 和 操作chrome浏览器的类库使用总结 1. 常见标准 1 1.1. 录制重放 1 1.2. 一个窗体一个proxy cookie 1 1.3. exec ...

  6. Selenium Webdriver java 积累一

    Selenium Webdriver 学习: http://jarvi.iteye.com/category/203994 https://github.com/easonhan007/webdriv ...

  7. Selenium webdriver 操作chrome 浏览器

    Step1: 下载chromedriver. 下载路径: http://chromedriver.storage.googleapis.com/index.html 选择一个合适的下载即可.我下载的是 ...

  8. Python3.5+selenium操作Chrome浏览器

    1.安装selenium 命令提示符下输入: pip install selenium 2.下载chromedriver 点击下载 3.将解压后的chromedriver.exe放到chrome浏览器 ...

  9. [selenium webdriver Java]元素定位——findElement/findElements

    策略 语法 语法 描述 By id driver.findElement(By.id()) driver.findElements(By.id()) 通过id属性定位元素 By name driver ...

随机推荐

  1. layer close 关闭层IE9-浏览器崩溃问题解决

    针对ayer弹出层在IE上关闭导致浏览器崩溃的问题: 导致原因: 查看src源码,layer.close关闭总方法中有这么一行: layer.close = function(index){ ] + ...

  2. AC日记——Card Game codeforces 808f

    F - Card Game 思路: 题意: 有n张卡片,每张卡片三个值,pi,ci,li: 要求选出几张卡片使得pi之和大于等于给定值: 同时,任意两两ci之和不得为素数: 求选出的li的最小值,如果 ...

  3. AC日记——[SCOI2012]喵星球上的点名 bzoj 2754

    2754 思路: AC自动机暴力处理匹配: 强大的ac自动机,强大的fail树,强大的map,强大的vector,强大的指针: 代码: #include <map> #include &l ...

  4. [libGDX游戏开发教程]使用libGDX进行游戏开发(12)-Action动画

    前文章节列表:  使用libGDX进行游戏开发(11)-高级编程技巧   使用libGDX进行游戏开发(10)-音乐音效不求人,程序员也可以DIY   使用libGDX进行游戏开发(9)-场景过渡   ...

  5. 【转】持续集成 Sonar 平台搭建及 Sonar 自定义规则打包部署篇

    引言 基于阿里开发手册的sonar自定义插件工程 开源地址: https://github.com/tigerge000/sonar-java-custom-rules.git由于最近来问童鞋,就算写 ...

  6. SQL 插入多行数据语句整理

     参考别人的,希望对大家有用. 1.只是插入简单的有限行数据时用: insert 要插入的表名(列名1,列名2,....) select '列名1需要的数据','列名2需要的数据',... union ...

  7. HDU 6213 Chinese Zodiac 【模拟/水题/生肖】

    Problem Description The Chinese Zodiac, known as Sheng Xiao, is based on a twelve-year cycle, each y ...

  8. Hash算法详解

    这篇不错: https://blog.csdn.net/u014209205/article/details/80820263

  9. SNMP OID批量枚举工具

    SNMP OID批量枚举工具   SNMP信息包含大量的系统.设备信息.这些信息均使用OID方式表示.由于OID编号规则复杂,不便于记忆.为了快速通过OID批量获取指定信息,Kali Linux新增了 ...

  10. 【并查集】bzoj2054 疯狂的馒头

    因为只有最后被染上的颜色会造成影响,所以倒着处理,用并查集维护已经染色的区间的右端点,即fa[i]为i所在的已染色区间的右端点,这样可以保证O(n)的复杂度. #include<cstdio&g ...