java+selenium环境搭建




1、安装、配置JDK1.6
配置JAVA_HOME
右击我的电脑-->属性-->高级系统设置-->高级-->环境变量

java+selenium环境搭建_第1张图片


java+selenium环境搭建_第2张图片

Path中增加%JAVA_HOME%\bin;

java+selenium环境搭建_第3张图片


2Java IDE中引用selenium-java-2.40.0.jarselenium-server-standalone-2.40.0.jar

项目目录右键-->Build Path--> config build path-->Java BuildPath-->Libraries-->Add External JARs,添加selenium-java-2.40.0.jarselenium-server-standalone-2.40.0.jar

java+selenium环境搭建_第4张图片


3、拷贝chromedriver.exesystem32目录,安装chrome浏览器


4、测试环境是否搭建成功

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class test1 {
	public static void main(String[] args) throws InterruptedException {
		WebDriver dr = new ChromeDriver();
		dr.get("http://www.baidu.com");	//打开首页
		dr.manage().window().maximize();	//最大化
		Thread.sleep(3000);
		dr.quit();
	}
}




你可能感兴趣的:(selenium,自动化测试,java+selenium)