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/,根据编写测试脚本所使用的语言下 ...
随机推荐
- mvc 导入excel表格
<script> $(function () { $("#Attachment").change(function () { var att = $("#At ...
- npm install socket.io遇到的问题
解决方法: 输入 npm install socket.io 前,先执行下面 npm config set proxy "http://yourip:port" 生产的npm-de ...
- Android菜鸟成长记12 -- ORMLite的简单使用
在我们的开发中,为了提高开发效率,我们一般都会使用到框架,ormilte则是我们必不可少的数据库框架. 对于ORMLite我也是今天才刚刚接触,我们先从一个简单的项目来了解它吧. ORMLite ja ...
- 事件:卸载事件(onunload)
这是几点应卸载事件的说明 ①目前试了Firefox.Google Chrome.IE三个浏览器,该事件只对IE起作用. ②onunload事件对于刷新页面和超链接跳转其他页面情况有效,对于关闭页面无效 ...
- Struts2------通配符
<struts> <package namespace="/" extends="struts-default" name="tes ...
- oracle 队列
Oracle 高级队列(AQ) 适用对象:初步了解oracle高级队列人群 注意事项: 序号 注意事项 1 JMS监听部分可参考官方文档: http://docs.oracle.com/cd/e128 ...
- CentOS 6.5 下离线安装nginx
一.由于linux下安装nginx 需要 zlib zlib-devel openssl openssl-devel pcre pcre-devel gcc这些依赖,而这些依赖打安装包在我们系统的光 ...
- AD账号创建日期、最近一次登录时间、最近一次重置密码时间查询
一:查询此AD域内所有用户的创建日期 Get-ADuser -filter * -Properties * | Select-Object Name,SID, Created,PasswordLas ...
- 在子线程中new Handler报错--Can't create handler inside thread that has not called Looper.prepare()
在子线程中new一个Handler为什么会报以下错误? java.lang.RuntimeException: Can't create handler inside thread that has ...
- ajax的表单提交,与传送数据
ajax的表单提交 $.ajax ({ url: "<%=basePath%>resource/addPortDetectOne.action", dataType: ...