1、安装jdk并配置环境变量:

jdk安装
jdk下载地址: http://www.oracle.com/technetwork/java/javase/downloads/index.html
环境变量配置,如:
CLASSPATH=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
JAVA_HOME=D:\Program Files\Java\jdk1.6.0_10
PATH=%JAVA_HOME%\bin

2、安装Firefox,Selenium IDE,Firebug和xpahter

安装FireFox

Firefox版本有一定限制,需要和selenium IDE相匹配。
下载地址: http://www.firefox.com.cn/download/

安装Selenium IDE
Selenium IDE是基于FIREFOX浏览器的一个插件,提供GUI界面来运行Selenium测试。Selenium IDE提供脚本录制和回放功能,可以将用户在浏览器中执行的操作记录下来,生成各种形式的脚本,可以将这些脚本保存供selenium使用。Selenium IDE主要是用在Selenium 1.0中,在Selenium 2.0中基本不使用。
1)下载Selenim IDE
下载地址:http://seleniumhq.org/projects/ide/

2)安装:直接把下载的Selenium IDE文件拖到FireFox浏览器窗口中,按提示操作即可安装成功。

安装Firebug
1)打开Firefox浏览器
2)点击菜单“工具(T)”,下拉列表中选择“附加组件”。
3)“获取附加组件”
4)在搜索里输入“firebug”,稍等即可。
5)点击“添加至Firefox”
6)OK,重启浏览器即可。

安装xpahter
1)打开Firefox浏览器
2)点击菜单“工具(T)”,下拉列表中选择“附加组件”。
3)“获取附加组件”
4)在搜索里输入“xpahter”,稍等即可。
5)点击“添加至Firefox”
6)OK,重启浏览器即可。

安装xpath checker

1)打开Firefox浏览器
2)点击菜单“工具(T)”,下拉列表中选择“附加组件”。
3)“获取附加组件”
4)在搜索里输入“xpath checker”,稍等即可。
5)点击“添加至Firefox”
6)OK,重启浏览器即可。

3、安装eclipse

安装eclipse

4、安装selenium webdriver

1)下载地址: http://code.google.com/p/selenium/downloads/list

官方UserGuide:http://seleniumhq.org/docs/

2)下载:selenium-server-standalone-2.44.0.jar和selenium-java-2.44.0.zip(使用java语言的下载该包)。 
3)解压下载的selenium-java-2.44.0.zip文件

5、selenium2使用:

1)在Eclipse里新建一个project,然后引用selenium-java-2.44.0.zip解压后的selenium-java-2.44.0.jar,及libs下的jar包。

2)新建一个class“Seleniumcn”把代码贴进去,如果代码没错误就可以运行了。例如下面:

package com.hxh.test;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.BeforeClass;
import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium; public class SeleniumTest{
private WebDriver driver;
@BeforeMethod
@BeforeClass
public void setUp(){
System.setProperty("webdriver.ie.driver", "C:\\Program Files (x86)\\Internet Explorer\\IEDriverServer.exe");
driver = new InternetExplorerDriver();
} @Test(invocationCount=3)
public void testLogic(){
driver.get("http://www.baidu.com/");
System.out.println("打开链接——>");
WebDriverWait wait = new WebDriverWait(driver, 100);
WebElement element = wait.until(new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver d) {
return d.findElement(By.id("kw"));
}
});
if(element!=null){
System.out.println("成功打开连接~~~~~~~~O(∩_∩)O~");
}
} @AfterMethod
public void tearDown(){
if(driver!=null){
driver.quit();
}
}
}

正常运行后,这几行代码将会打开IE浏览器,然后转跳到百度首页。

并关闭IE浏览器。

(以上内容参考群共享某word资料,不知具体作者是谁哈~)

selenium2(WebDriver)环境搭建的更多相关文章

  1. Selenium2 WebDriver环境搭建

    1.下载Selenium Client Servers包 在Selenium官网上可以下载到最新的开源的包http://seleniumhq.org/download/,根据编写测试脚本所使用的语言下 ...

  2. Python+Selenium+webdriver环境搭建(windows)以及相关资源下载链接

    今天记录一下测试小菜鸟alter在测试入门的一点关于python+Selenium+webdriver环境搭建的经历以及资源分享.欢迎交流学习,批评指正. 一.Python的下载与安装 1.pytho ...

  3. webDriver环境搭建与测试

    1.安装jdk 2.安装eclipse 3.安装selenium 由于使用的是开发语言是java,因此需要安装java版的selenium包.下载地址:http://pan.baidu.com/s/1 ...

  4. 转:python webdriver 环境搭建

    第一节 环境搭建准备工具如下:-------------------------------------------------------------下载 python[python 开发环境]ht ...

  5. RobotFramework+Selenium2+Appium环境搭建

    转载:https://www.cnblogs.com/testway/p/7372326.html 装python 2.7 RobotFramework是python2 写的,图形界面使用的wxpyt ...

  6. python webdriver 环境搭建详解

    学了一个月用java编写selenium driver 测试脚本,也将公司做的系统基本可用的模块做了一次自动化,虽然写的比较简陋,但是基本可用跑一遍,并用testNG生成了测试报告. 学习方式无非是: ...

  7. 百度搜索_Selenium WebDriver 环境搭建和错误调试_chromedriver_win32必须下载否则无法测试chrome

    转自:  http://www.360doc.com/content/14/0821/18/597197_403634783.shtml zTree 东西不多,我也一直使用着原始的人工测试手段,随着内 ...

  8. Windows环境下,python webdriver环境搭建

    最近刚开始学习selenium,这是我从虫师的<selenium2自动测试实战--基于Python语言>这本书上学到搭建环境的步骤,里面有加上我的一些总结,希望对大家有所帮助!   准备工 ...

  9. selenium webdriver 环境搭建--java

    selenium java环境的安装可以分为三个部分:jdk.eclipse和selenium. jdk jdk(java development kit)是sun公司针对java开发人员的产品,是整 ...

  10. 二. Python WebDriver环境搭建

    1. 安装Selenium 在命令行中输入: 显示安装成功: 2. 测试例子 打开百度页面并在输入框输入搜索内容(默认为firework) # 1. Selenium默认为Firefox.验证 fro ...

随机推荐

  1. ssh 的搭建

    struts包的下载:http://struts.apache.org/download.cgi#struts252 string包的下载: http://repo.spring.io/release ...

  2. C#中如何定义全局变量及在各窗体中使用全局变量

    using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; us ...

  3. 构建最小的docker容器

    创建一个最小的基本镜像: tar cv --files-from /dev/null | sudo docker import - skycn/base 建一个hello.go: package ma ...

  4. AngularJS-chapter1-2-四大特性

    4大特性 MVC MVC实例  数据模型,控制器,视图 HelloAngular_MVC.html 图中的 ng-controller="HelloAngular"  定义了Hel ...

  5. The source attachment does not contain the source for the file  ActionSupport.class 错误

    报错  Syntax error, insert ";" to complete FieldDeclaration 报错   The source attachment does ...

  6. cs11_c++_lab6

    expressions.hh #ifndef EXPRESSIONS_HH #define EXPRESSIONS_HH #include "environment.hh" #in ...

  7. java静态和动态代理原理

    一.代理概念 为某个对象提供一个代理,以控制对这个对象的访问. 代理类和委托类有共同的父类或父接口,这样在任何使用委托类对象的地方都可以用代理对象替代.代理类负责请求的预处理.过滤.将请求分派给委托类 ...

  8. Ajax请求数据

    后台使用数数组的形式存放数据(以键值对的形式存放).让后再Json转码. Map<String,String> map=new HashMap<String,String>() ...

  9. Foundation ----->NSSet

    1.集合类     NSString *s1 = @"zhangsan";     NSString *s2 = @"lisi";     NSString * ...

  10. ios10 no route to host

    IdTCPClient1 ios10 no route to host IOS 9 正常 IOS10 出错,参考下面的设置解决问题 http://www.sh-huhe.com/solution/14 ...