web自动化(1)----selenium环境搭建
来源:互联网 发布:淘宝内衣向大大 编辑:程序博客网 时间:2024/06/08 04:08
一篇总结的很完整的博客:
http://www.cnblogs.com/TankXiao/p/5260445.html
selenium2.0=selenium1.0+webdriver
selenium1.0是将javascript代码注入到对应的网站里面,模拟JS操作。
webdriver的原理是调用各个浏览器的底层JavaScript框架,模拟各种JS操作。
既然调用各个浏览器自己的底层JavaScript框架,那么除了selenium默认支持的火狐浏览器以外,都需要一个驱动。我们的环境搭建从驱动开始。
此处使用谷歌浏览器。
(1)ChromeDriver下载
地址:http://npm.taobao.org/mirrors/chromedriver
进去后选择最新版本的下载,解压后直接使用
(2)创建一个selenium的maven jnuit项目,POM设置
<dependencies><dependency><groupId>org.seleniumhq.selenium</groupId><artifactId>selenium-java</artifactId><version>2.48.2</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version></dependency></dependencies>(3)下载对应的谷歌浏览器版本,selnium和ChromeDriver对应不同的谷歌浏览器版本,启动用例后会自动提醒
(4)启动浏览器的代码
System.setProperty("webdriver.chrome.driver","C:\\Users\\Administrator\\Desktop\\chromedriver.exe");ChromeOptions options = new ChromeOptions(); options.setBinary("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");WebDriver driver = new ChromeDriver(options);driver.get("http://www.baidu.com");注意:(1)需要将谷歌浏览器驱动地址设置成系统值
(2)谷歌浏览器地址需要转换成二进制才能打开
0 0
- web自动化(1)----selenium环境搭建
- Web自动化环境搭建(selenium+python)
- selenium web 自动化环境搭建(Windows7 环境, Chrome, Python)
- Selenium+TestNG Web自动化测试环境搭建1_前言
- Selenium+Python Web自动化测试环境搭建
- Selenium+TestNG Web自动化测试环境搭建3_xpath学习
- selenium + Python 自动化环境搭建
- Python+selenium自动化环境搭建
- Python+selenium自动化环境搭建
- Selenium+Java+Appium+TestNg环境搭建——Web自动化测试与HTML5测试(2)
- Selenium+TestNG Web自动化测试环境搭建9_ANT自动化执行以及testNG报告优化
- 1、Selenium + Python 实现 UI 自动化测试-环境搭建
- 如何搭建Selenium-Grid2环境(Java)(自动化测试技术)
- 自动化基本环境搭建 (myEclipse + selenium-2.42.2)
- Selenium终极自动化测试环境搭建(一)
- UI自动化测试环境搭建步骤(python + selenium)
- Java+maven+selenium+testng+jenkins自动化环境搭建(补充)
- selenium+python自动化测试(一)--环境搭建
- 单链表(c语言版)
- float数据在内存中的存储方法
- APIO2012 dispatching(dfs序+主席树)
- 【Html】类和ID选择器的区别
- 系统操作日志设计-代码实现
- web自动化(1)----selenium环境搭建
- struts2国际化
- Javascript深入浅出之基本类型
- Scala 点滴:"_" 方法 -> 函数
- ContentProvider 详解
- hdu 1034 Candy Sharing Game
- TCMalloc小记
- nyoj99(欧拉路)
- OAF学习笔记-不基于EO的数据处理