Selenium WebDriver 3.0 需要注意的事项
以下所有代码基于Java
首先,要使用WebDriver 3.0 的话 请使用JAVA 8(必要)
其次,由于W3C标准化以及各大浏览器厂商的积极跟进,自WebDriver 3.0 之后,Selenium不再提供默认的浏览器支持. 也就是说
如果你要使用Firefox, 就需要用到Mozilla自己的驱动实现: geckodriver ,这里是github下载地址 https://github.com/mozilla/geckodriver/releases
一个简单的例子
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "d:\\geckodriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(capabilities);
}
如果你要使用Edge,就需要用到MS的WebDriver, 地址在这里:https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
一个简单的例子
public static void main(String[] args) {
System.setProperty("webdriver.edge.driver","d:\\MicrosoftWebDriver.exe"); //put actual location
WebDriver driver = new EdgeDriver();
driver.get("https://www.google.com");
}
如果你要使用IE,现在只支持IE9以上版本(老版本或许也能使用), 使用方式和Webdriver 2.0 没有区别,你需要先下载InternetExplorerDriver.exe 地址在这里:https://pan.baidu.com/s/1i4Td8ax 注意64位或者32位
一个简单的例子
public static void main(String[] args) {
System.setProperty("webdriver.ie.driver",
"../QACommon/src/main/resources/IEDriverServer.exe");
DesiredCapabilities ieCapabilities = DesiredCapabilities
.internetExplorer();
ieCapabilities.setCapability(
InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
true);
WebDriver driver = new InternetExplorerDriver(ieCapabilities);
}
如果你要使用Chrome, 和WebDriver 2.0 一样,你需要下载chromedriver驱动. 最新的地址在这里:http://chromedriver.storage.googleapis.com/index.html?path=2.25/
一个简单的例子
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "d:\\chromedriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
WebDriver driver = new ChromeDriver(capabilities);
driver.get("http://www.google.com");
}
Selenium WebDriver 3.0 需要注意的事项的更多相关文章
- selenium webdriver 的环境搭建时注意事项
selenium webdriver 在 eclipse中的配置,网络上应该很方便搜索到,这里只记搭建过程中容易出现的一些问题 1. selenium-java与selenium-sever-sta ...
- Selenium WebDriver 2.34.0 发布,支持Firefox22
Selenium WebDriver 2.34.0 发布,支持Firefox22http://automationqa.com/forum.php?mod=viewthread&tid=270 ...
- java.lang.UnsupportedClassVersionError: org/openqa/selenium/WebDriver : Unsupported major.minor version 51.0
周一上班,正常打开myeclipse,随便写了一个main方法执行.发现报错了... 问题提示如下: java.lang.UnsupportedClassVersionError: org/openq ...
- selenium webdriver自动化测试
selenium家族介绍 Selenium IDE:Selenium IDE是嵌入到Firefox浏览器中的一个插件,实现简单的浏览器操作的录制与回放功能. Selenium ...
- 【自动化测试&爬虫系列】Selenium Webdriver
文章来源:公众号-智能化IT系统. 一. Selenium Webdriver技术介绍 1. 简介 selenium Webdriver是一套针对不同浏览器而开发的web应用自动化测试代码库.使用这套 ...
- 使用httpclient 调用selenium webdriver
结合上次研究的selenium webdriver potocol ,自己写http request调用remote driver代替selenium API selenium web driver ...
- selenium webdriver 右键另存为下载文件(结合robot and autoIt)
首先感谢Lakshay Sharma 大神的指导 最近一直在研究selenium webdriver右键菜单,发现selenium webdriver 无法操作浏览器右键菜单,如图 如果我想右键另存为 ...
- Selenium Webdriver下click失效问题解决
最近在使用Selenium Webdriver(Selenium2.0)进行界面自动化测试的时候发现单击事件无效,通过driver.findElement的方式是可以找到click元素的,但是就是cl ...
- Selenium WebDriver 之 PageObjects 模式 by Example
目录 1. 项目配置 2. 一个WebDriver简单例子 3. 使用Page Objects模式 4. 总结 5. Troubleshooting 6. 参考文档 本篇文章通过例子来阐述一下Sele ...
随机推荐
- vps_centos_7_系统环境常规配置备忘
1.设置时区(东八区) 1> 选择亚洲东八区北京时间:tzselect (按照提示选择指定的序号直到北京时间) 2>替换时区文件 :cp /usr/share/zoneinfo/Asia/ ...
- github push时,要求密码的问题
整几次才搞的有点明白: 1 clone 项目 用 SSH: 在github 上如下图 2 C:\Users\<用户名> 下如果有 "_netrc" 文件: 如果含有 如 ...
- 闲来无事,写个基于TCP协议的Socket通讯Demo
.Net Socket通讯可以使用Socket类,也可以使用 TcpClient. TcpListener 和 UdpClient类.我这里使用的是Socket类,Tcp协议. 程序很简单,一个命令行 ...
- BAT 技术团队博客
1. 美团技术团队博客: 地址: http://tech.meituan.com/ 2. 腾讯社交用户体验设计(ISUX) 地址:http://isux.tencent.com/ 3. 京东设计中心 ...
- javascript系列:NaN类型
NaN,即非数值是一个特殊的数值,这个数值用于表示一个本来要返回数值的操作数未返回数值的情况下. ECMAScript中任何数值除以0会返回NaN,因此不影响其他代码运行. NaN特点: ...
- sublime text 插件(前端自用)
一.软件安装 ST中文论坛:http://sublimetext.iaixue.com/ 或者 http://sublimetext.iaixue.com/dl/#sublime_text_3103 ...
- div样式text-align在子元素缩进不规范的情况下,chrome出现的问题(貌似结果是inline-block导致的)
在调css的时候,发现居然有firefox实现效果完整而chrome出现问题的情况: 详细情况:segmentfault1 segmentfault2 全文表达: <html><he ...
- Reading C type declarations(引用http://unixwiz.net/techtips/reading-cdecl.html)
Even relatively new C programmers have no trouble reading simple C declarations such as int foo[5]; ...
- 移动端图片上传base64编码
$base64 = "/9j/4AAQSkZJRgABAQEAkACQAAD/4QCMRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAA ...
- 一些值得练习的github项目
简单粗暴,一晚上用 node.Vue 写个联机五子棋 https://github.com/ccforward/cc/issues/51 Vue2.0实现简易豆瓣电影webApp https://gi ...