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/,根据编写测试脚本所使用的语言下 ...
随机推荐
- Topcoder几例C++字符串应用
本文写于9月初,是利用Topcoder准备应聘时的机试环节临时补习的C++的一部分内容.签约之后,没有再进行练习,此文暂告一段落. 换句话说,就是本文太监了,一直做草稿看着别扭,删掉又觉得可惜,索性发 ...
- Portable Basemap Server:多数据源多客户端的底图服务器
Portable Basemap Server:多数据源多客户端的底图服务器 [poll id=”1″]2014.3.8更新v3.1~在线切片转换为MBTiles时,增加RecreateEmptyCa ...
- 1全志 A20 camera移植
转自 http://www.right.com.cn/forum/thread-146260-1-1.html 在Android4.0升级后,突然发现大量平台对Camera的支持均非常不好.要么C ...
- Session和Cookie的作用以及实现
http://www.cnblogs.com/xiaoshitoutest/p/6103790.html
- 如何在HTML中加载Flash(2种实现方法)_HTML/Xhtml_网页制作
点评:如何在HTML中加载Flash,为网页添加更多的色彩,普通的网页以无法满足用户的需求,接下来为大家介绍下2种在HTML中加载Flash的方法,感兴趣的各位可以适当参考下,希望对你有所帮助 第一种 ...
- SeekBar 圆角问题
用图片做背景色,最后处理成.9.png的.用普通png图片做背景,则两边会有圆角出现,原因是图片不适合SeekBar尺寸,因而被拉伸或压缩,从而产生圆角. <?xml version=" ...
- Fortran 笔记
1.将字符串写入文本 open(,File=trim("e:\XRIVER_LOG.txt"), ACCESS = 'APPEND')!ACCESS = 'APPEND' 在文本末 ...
- java环境配置步骤
1. jdk下载 官网:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html ...
- 安装运行okvis
1. 安装依赖项 sudo apt-get install cmake //cmake sudo apt-get install libgoogle-glog-dev // glog是Googl ...
- opencv单目摄像机标定
#include <cv.h> #include <highgui.h> #include <iostream> #include <stdio.h> ...