webDriver环境搭建与测试
1、安装jdk
2、安装eclipse
3、安装selenium
由于使用的是开发语言是java,因此需要安装java版的selenium包。下载地址:http://pan.baidu.com/s/1hq6mebE,下载的版本为:selenium-java-2.53.0。下载完成后,进行解压,得到如下目录:

下载完jar包后,在已经创建的项目上右键,选择properties,选择java Build Path,选择导入额外的jar包,详情如下:

导入jar包后:

4、安装浏览器驱动
Firefox--selenium原生支持,不需要安装浏览器驱动
IE--需要安装浏览器驱动
chrome--需要安装浏览器驱动
以IE为例:
首先下载IEDriverServer.exe,将该驱动防止到IE浏览器安装路径下:C:\Program Files (x86)\Internet Explorer
配置系统路径path,配置如下:

5、接下来编写一个简单的程序,测试环境搭建是否通过
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.chrome.*;
import org.openqa.selenium.ie.*;
public class WebDriverLearn {
WebDriver driver = new InternetExplorerDriver();
driver.get("https://www.baidu.com/");
}
}
运行:
报错如下:
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.ie.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver. The latest version can be downloaded from http://selenium-release.storage.googleapis.com/index.html
at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
at org.openqa.selenium.ie.InternetExplorerDriverService.access$0(InternetExplorerDriverService.java:1)
at org.openqa.selenium.ie.InternetExplorerDriverService$Builder.findDefaultExecutable(InternetExplorerDriverService.java:167)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at org.openqa.selenium.ie.InternetExplorerDriver.setupService(InternetExplorerDriver.java:251)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:172)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:146)
at WebDriverLearn.main(WebDriverLearn.java:27)
报错原因:
找不到IE浏览器相关文件,需要设置下system property。利用System.setProperty方法来添加路径,代码更新如下:
import org.openqa.selenium.*;
import org.openqa.selenium.ie.*;
public class WebDriverLearn {
public static void main(String[] args) {
System.setProperty("webdriver.ie.driver", "C:/Program Files (x86)/Internet Explorer/IEDriverServer.exe"); //指定IE浏览器安装路径
WebDriver driver = new InternetExplorerDriver();
driver.get("https://www.baidu.com/");
}
}
运行本段代码,能够顺利打开IE浏览器。
注意:本文使用的selenium-java-2.53.0.jar,IE浏览器为IE9.
selenium和不同的浏览器,会有不同的兼容性问题,需要选择正确的相互兼容的selenium和浏览器。目前只找到selenium-java-2.53.0.jar和IE9兼容.
webDriver环境搭建与测试的更多相关文章
- Python+Selenium+webdriver环境搭建(windows)以及相关资源下载链接
今天记录一下测试小菜鸟alter在测试入门的一点关于python+Selenium+webdriver环境搭建的经历以及资源分享.欢迎交流学习,批评指正. 一.Python的下载与安装 1.pytho ...
- Tensorflow object detection API ——环境搭建与测试
1.开发环境搭建 ①.安装Anaconda 建议选择 Anaconda3-5.0.1 版本,已经集成大多数库,并将其作为默认python版本(3.6.3),配置好环境变量(Anaconda安装则已经配 ...
- 【运维技术】kafka三实例集群环境搭建及测试使用
kafka三实例集群环境搭建及测试使用 单机搭建分为两部分:1. 软件安装启动 2. 软件配置 软件安装启动: # 切换到目录 cd /app # 获取kafka最新安装包,这边使用的是镜像地址,可以 ...
- Tensorflow object detection API(1)---环境搭建与测试
参考: https://blog.csdn.net/dy_guox/article/details/79081499 https://blog.csdn.net/u010103202/article/ ...
- C++调用Lua编程环境搭建及测试代码示例
C++调用Lua编程环境搭建及测试代码示例 摘要:测试环境是VS2005+LuaForWindows_v5.1.4-45.exe+WIN7 1.安装lua开发环境LuaForWindows_v5.1. ...
- 【转载】基于RedHatEnterpriseLinux V7(RHEL7)下SPEC CPU 2006环境搭建以及测试流程(之一)——介绍、安装准备、安装、config文件以及运行脚本介绍
基于RedHatEnterpriseLinux V7(RHEL7)下SPEC CPU 2006环境搭建以及测试流程(之一)--介绍.安装准备.安装.config文件以及运行脚本介绍 其他 2018-0 ...
- Mybatis环境搭建及测试
1.新建java project,导入相应jar包 本次使用到的mybatis-3.2.7版本 mybatis需要jar包:mybatis-3.2.7.jar.lib文件下的依赖jar mysql驱动 ...
- 转:python webdriver 环境搭建
第一节 环境搭建准备工具如下:-------------------------------------------------------------下载 python[python 开发环境]ht ...
- Selenium2 WebDriver环境搭建
1.下载Selenium Client Servers包 在Selenium官网上可以下载到最新的开源的包http://seleniumhq.org/download/,根据编写测试脚本所使用的语言下 ...
随机推荐
- linux 学习 14 日志管理
第十四讲 日志管理 14.1 日志管理-简介 .日志服务 在CentOS .x中日志服务已经由rsyslogd取代了原先的syslogd服务.rsyslogd日志服务更加先进,功能更多.但是不论该服 ...
- windows下运行的linux服务器批量管理工具(带UI界面)
产生背景: 由于做服务器运维方面的工作,需要一人对近千台LINUX服务器进行统一集中的管理,如同时批量对LINUX服务器执行相关的指令.同时批量对LINUX服务器upload程序包.同时批量对LINU ...
- MFC 获取图像的大小
// 获致图像的大小 int CCImageDialog::GetImageSize(CSize& size, CString filename) { CImage image; image. ...
- BASE64编码和解码(VC源代码) 并 内存加载 CImage 图像
BASE64可以用来将binary的字节序列数据编码成ASCII字符序列构成的文本.完整的BASE64定义可见 RFC1421和 RFC2045.编码后的数据比原始数据略长,为原来的4/3.在电子 ...
- Linux性能工具介绍
l Linux性能工具介绍 p CPU高 p 磁盘I/O p 网络 p 内存 p 应用程序跟踪 l 操作系统与应用程序的关系比喻为“唇亡齿寒”一点不为过 l 应用程序的性能问题/功能问 ...
- [转载] 纯手打 第一篇:安装配置gradle
本文转载自: http://www.cnblogs.com/uncle2000/p/4276833.html 一个bug 一个脚印的叫你们用gradle. 1介于网络上的很多资料都是老的 不适用与现在 ...
- LeetCode之Largest Rectangle in Histogram浅析
首先上题目 Given n non-negative integers representing the histogram's bar height where the width of each ...
- linux 命令之comm
1. 简介 comm命令可以用于两个文件之间的比较,它有一些选项可以用来调整输出,以便执行交集.求差.以及差集操作. 交集:打印出两个文件所共有的行. 求差:打印出指定文件所包含的且不相同的行. 差集 ...
- HDU 2295 Radar (重复覆盖)
Radar Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- 简单的html和css
整体图太大了,看不太清楚,下面是分开的图 第一张: 第二张: