1.下载jdk1.8   环境变量我的博客有我就不说                   selenium下载地址:http://npm.taobao.org/mirrors/selenium

2.下载eplise  网盘地址:链接:https://pan.baidu.com/s/1zXtQHY5hb2IBolA0PhmmJg 密码:bol4

3.使用WebDriver在Chrome浏览器上进行测试时,需要从http://chromedriver.storage.googleapis.com/index.html网址中下载与本机chrome浏览器对应的驱动程序,驱动程序名为chromedriver;

4.火狐驱动下载地址:https://github.com/mozilla/geckodriver/releases/

5.IE的驱动IEdriver 下载地址:http://www.nuget.org/packages/Selenium.WebDriver.IEDriver/

火狐驱动:http://ftp.mozilla.org/pub/firefox/releases/

谷歌驱动:http://npm.taobao.org/mirrors/chromedriver/

selenium3.5

firefox 55.0

Firefox driver geckodriver-v0.19.0-win64.zip

各种火狐浏览器版本下载:http://ftp.mozilla.org/pub/firefox/releases/

方法一 添加jar包

官方下载地址: http://www.seleniumhq.org/download/

我的网盘地址: https://pan.baidu.com/s/1zXtQHY5hb2IBolA0PhmmJg 密码:bol4

解压后有四个文件:

2. 添加build path,  项目目录右键 Build Path -> Config build path -> java build Path -> Libraries -> Add JAR

3. 把libs 文件夹下的jar包,全部添加上,再添加 selenium-java-2.44.0-src.jar和selenium-java-2.44.0.jar

方法二 直接引用selenium-server-standalone.jar

selenium-server-standalone.jar 下载地址也在: http://pan.baidu.com/s/1c1tD6Kw

将selenium-server-standalone.jar 直接添加到java项目中就可以了

//如果要引入其他包

import org.openqa.selenium.*;

import org.openqa.selenium.chrome.*;

火狐浏览器:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class demo {

public static void main(String[] args) {
// TODO Auto-generated method stub

System.setProperty("webdriver.firefox.bin","E:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.baidu.com/");

driver.quit();
}

}

谷歌浏览器:

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

public class demo {

public static void main(String[] args) {
// TODO Auto-generated method stub

System.setProperty("webdriver.chrome.driver","你的谷歌驱动地址,切记路径用//");
WebDriver driver = new ChromeDriver();
driver.get("https://www.baidu.com/");

driver.quit();
}

}

IE浏览器

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

public class demo {

public static void main(String[] args) {
// TODO Auto-generated method stub

System.setProperty("webdriver.ie.driver","你的IE驱动地址,切记路径用//");
WebDriver driver = new lnternetExplorerDriver();
driver.get("https://www.baidu.com/");

driver.quit();
}

}

谷歌浏览器地址:https://www.chromedownloads.net/chrome64win-beta/

下载地址:http://selenium-release.storage.googleapis.com/index.html

火狐驱动日志地址:https://github.com/mozilla/geckodriver/blob/release/CHANGES.md

chromedriver版本 支持的Chrome版本
v2.38 v65-67
v2.37 v64-66
v2.36 v63-65
v2.35 v62-64
v2.34 v61-63
v2.33 v60-62
v2.32 v59-61
v2.31 v58-60
v2.30 v58-60
v2.29 v56-58
v2.28 v55-57
v2.27 v54-56
v2.26 v53-55
v2.25 v53-55
v2.24 v52-54
v2.23 v51-53
v2.22 v49-52
v2.21 v46-50
v2.20 v43-48
v2.19 v43-47
v2.18 v43-46
v2.17 v42-43
v2.13 v42-45
v2.15 v40-43
v2.14 v39-42
v2.13 v38-41
v2.12 v36-40
v2.11 v36-40
v2.10 v33-36
v2.9 v31-34
v2.8 v30-33
v2.7 v30-33
v2.6 v29-32
v2.5 v29-32
v2.4 v29-32

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 public static void StartFireFoxLoadPlugin(){
System.out.println("start firefox browser...");
System.setProperty("webdriver.firefox.bin",
"D:/Program Files/Mozilla Firefox/firefox.exe");
File file = new File("files/firebug-1.9.0-fx.xpi");
FirefoxProfile profile = new FirefoxProfile();
try {
profile.addExtension(file);
} catch (IOException e) {
e.printStackTrace();
}
//设置firebug版本
profile.setPreference("extensions.firebug.currentVersion", "1.9.0");
//自动打开firebug
profile.setPreference("extensions.firebug.allPagesActivation", "on");
//设置启用firebug网络面板
profile.setPreference("extensions.firebug.net.enableSites", true);
//设置启用firebugcookies面板
profile.setPreference("extensions.firebug.cookies.enableSites", true); WebDriver driver = new FirefoxDriver(profile);
driver.get("http://www.baidu.com");
System.out.println("start firefox browser succeed...");
}

最新文章

  1. Apache rewrite
  2. 解决oracle服务器重启之后连接报错的问题
  3. JavaScript Emoji 表情库_js 类似于qq微信的表情库
  4. nginx安装详解
  5. CENTOS install summary
  6. JAVA从零单排之前因
  7. TCP/IP之TCP连接的建立与中止状态分析
  8. 游标遍历所有数据库循环执行修改数据库的sql命令
  9. 搭建Hadoop的环境
  10. QPalette
  11. [Swift]LeetCode386. 字典序排数 | Lexicographical Numbers
  12. JavaScript定义函数
  13. 嵌入式系统C编程之堆栈回溯【转】
  14. Vue.js 子组件的异步加载及其生命周期控制
  15. ssm学习的第一个demo---crm(3)
  16. 这几天bug多,自我检讨一下
  17. LINUX 下 NMAP 内网扫描
  18. CF 919 D. Substring
  19. ZH奶酪:标准偏差
  20. 微信小程序授权流程(图)

热门文章

  1. I'm studying Bootstrap! loading...
  2. Ubuntu18.04解决鼠标移动到Gnome顶栏左上角窗口不能平铺( Activites Overview 界面),和应用程序扩展不好用问题。
  3. shell脚本杀死某个服务的进程
  4. 1.什么是Cython
  5. 【转载】SQLITE3 使用总结
  6. WCF 无法激活服务,由于它不支持 ASP.NET 兼容性。已为此应用程序启用了 ASP.NET 兼容性
  7. Java 递归、尾递归、非递归 处理阶乘问题
  8. simple_strtoul()分析
  9. Document properties
  10. xBIM 基础06 将STEP物理文件转换为XML