使用selenium的WebDriver和ChromeDriver实现UI自动化
下载chromedriver
chromedriver与chrome的对应关系表:http://blog.csdn.net/huilan_same/article/details/51896672
下载地址:http://chromedriver.storage.googleapis.com/index.html
新建maven类型的JAVA项目,
添加依赖:
- <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
- <dependency>
- <groupId>org.seleniumhq.selenium</groupId>
- <artifactId>selenium-java</artifactId>
- <version>3.7.1</version>
- </dependency>
- <!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
- <dependency>
- <groupId>org.jsoup</groupId>
- <artifactId>jsoup</artifactId>
- <version>1.11.1</version>
- </dependency>
新建测试类
- package com.cctv.web.Selenium;
- import java.io.IOException;
- import org.jsoup.Jsoup;
- import org.jsoup.nodes.Document;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.chrome.ChromeDriver;
- import org.openqa.selenium.chrome.ChromeOptions;
- /**
- * Hello world!
- *
- */
- public class App
- {
- public static void main( String[] args )
- {
- System.setProperty("webdriver.chrome.driver", "C:\\Users\\chromedriver.exe");
- ChromeOptions options = new ChromeOptions();
- options.addArguments("--test-type","--no-check-certificate","--ignore-certificate-errors","--start-maximized","--disable-extensions");
- WebDriver driver = new ChromeDriver(options);
- driver.get("https://dev.iff-web.cctv.com");
- driver.findElement(By.id("username")).sendKeys("di");
- driver.findElement(By.id("password")).sendKeys("di");
- driver.findElement(By.id("kc-login")).click();
- //driver.findElementById("username").sendKeys("di");
- //driver.findElementById("password").sendKeys("di");
- //driver.findElementById("kc-login").click();
- try{
- Document doc=Jsoup.connect("http://dev.iff-web.cctv.com/device-manage?projectID=all&subsystemID=all").get();
- System.out.println(doc.toString());
- }catch (IOException e){
- e.printStackTrace();
- }
- }
- }
运行java应用时,会打开一个浏览器窗口,但窗口会报错:
网上找的方法试了很多,但是还是一直这样。
使用selenium的WebDriver和ChromeDriver实现UI自动化的更多相关文章
- WebDriver基本操作入门及UI自动化练手页面
在这里集中了我们在做UI自动化时常见的一些控件操作.希望能对新手有帮助. 下载地址:http://files.cnblogs.com/zhangfei/demo.rar package com.tes ...
- Selenium系列(十七) - Web UI 自动化基础实战(4)
如果你还想从头学起Selenium,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1680176.html 其次,如果你不懂前端基础知识, ...
- appium+python+jenkins+selenium grid+unnittest+生成报告打造UI自动化回归、监控体系
先放一下截图,展示一下平台做成的样子,以及实现后的结果,后面贴上自动化用例执行的过程中,帮我们发现的线上问题 关于appium自动化环境的安装,网上有很多教程,我就不重复赘述,后面陆续写出设计思想,贴 ...
- UI自动化(selenium+python)之浏览器驱动chromedriver安装和配置
一.安装selenium 前提是已安装Python,python安装 自行百度,这里不概述 安装好python后,cmd打开终端窗口-->pip命令安装 :pip install seleniu ...
- 【转】selenium及webdriver的原理
主要内容转自:http://blog.csdn.net/ant_ren/article/details/7968582和http://blog.csdn.net/ant_ren/article/det ...
- selenium及webdriver的原理
主要内容转自:http://blog.csdn.net/ant_ren/article/details/7968582和http://blog.csdn.net/ant_ren/article/det ...
- UI自动化(七)selenium简述
1.什么是ui自动化模拟人用代码的方式去操作页面2.为什么要做ui自动化后期迭代的时候,老功能比较多,人工维护成本大这时候考虑引入ui自动化3.什么时候做ui自动化项目稳定,不在修改的某些老功能,为这 ...
- UI自动化selenium
1.什么是UI自动化?模拟人用代码的方式去操作页面2.为什么要做UI自动化?后期迭代的时候,老功能比较多,人工维护成本较大,重复性工作较多,这个时候就考虑因为UI自动化3.什么时候做UI自动化?项目稳 ...
- Selenium:WebDriver简介及元素定位
参考内容:官方API文档,下载链接:http://download.csdn.net/detail/kwgkwg001/4004500 虫师:<selenium2自动化测试实战-基于python ...
随机推荐
- Jdeveloper下Svn的使用
Jdeveloper下Svn的使用 官方pdf:jdeveloper使用svn 官方网地址:http://www.oracle.com/technetwork/cn/java/subversion-0 ...
- SqlMapConfig.xml配置文件的配置内容
SqlMapConfig.xml中配置的内容和顺序如下: * properties(属性) * settings(全局配置参数) * typeAliases(类型别名) * typeHandlers( ...
- Chrome 强制刷新缓存的方法
https://jingyan.baidu.com/article/11c17a2c2a9e27f446e39d98.html
- python 中numpy的var,std及cov
var:表示方差, 即各项-均值的平方求和后再除以N , std:表示标准差,是var的平方根. cov:协方差 ,与var类似,但是除以(N-1)
- JSON.parse()和JSON.stringify()的使用
parse用于从一个字符串中解析出json对象,如 var str = '{"name":"huangxiaojian","age":&qu ...
- UVa 11136 Hoax or what (STL)
题意:有 n 天,每天有m个数,开始的前一天没有数据,然后每天从这个里面拿出一个最大的和最小的,求 n 天的最大的和最小的差值相加. 析:一看就知道用set啊,多简单的STL,不过要注意,开long ...
- tomcat服务器输入localhost可以访问,ip无法访问解决办法
最近在开发项目中,遇到的一个问题是: 在 tomcat中发布一个web项目,但是发布成功后,只能用http://localhost:8080/fm访问项目,不能用 http://127.0.0.1:8 ...
- OpenGl中的Nurbs B样条曲面的封装的GLU的NURBS的接口
OpenGl中的Nurbs B样条曲面的封装的GLU的NURBS的接口 创建一个NURBS对象: GLUnurbs* gluNewNurbsRenderer (void); //创建一个NURBS对象 ...
- 使用VMWare12.0安装Ubuntu系统
使用VMWare12.0安装Ubuntu系统 Vmware12的虚拟机的文档说明: http://pubs.vmware.com/workstation-12/index.jsp#com.vmware ...
- Give $20/month and provide 480 hours of free education
Hi , Hope all is well. Summer is right around the corner, and the Khan Academy team is excited to sp ...