下载chromedriver

chromedriver与chrome的对应关系表:http://blog.csdn.net/huilan_same/article/details/51896672

下载地址:http://chromedriver.storage.googleapis.com/index.html

新建maven类型的JAVA项目,

添加依赖:

  1. <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
  2. <dependency>
  3. <groupId>org.seleniumhq.selenium</groupId>
  4. <artifactId>selenium-java</artifactId>
  5. <version>3.7.1</version>
  6. </dependency>
  7. <!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
  8. <dependency>
  9. <groupId>org.jsoup</groupId>
  10. <artifactId>jsoup</artifactId>
  11. <version>1.11.1</version>
  12. </dependency>

  

新建测试类

  1. package com.cctv.web.Selenium;
  2.  
  3. import java.io.IOException;
  4.  
  5. import org.jsoup.Jsoup;
  6. import org.jsoup.nodes.Document;
  7. import org.openqa.selenium.By;
  8. import org.openqa.selenium.WebDriver;
  9. import org.openqa.selenium.chrome.ChromeDriver;
  10. import org.openqa.selenium.chrome.ChromeOptions;
  11.  
  12. /**
  13. * Hello world!
  14. *
  15. */
  16. public class App
  17. {
  18. public static void main( String[] args )
  19. {
  20. System.setProperty("webdriver.chrome.driver", "C:\\Users\\chromedriver.exe");
  21.  
  22. ChromeOptions options = new ChromeOptions();
  23. options.addArguments("--test-type","--no-check-certificate","--ignore-certificate-errors","--start-maximized","--disable-extensions");
  24.  
  25. WebDriver driver = new ChromeDriver(options);
  26. driver.get("https://dev.iff-web.cctv.com");
  27. driver.findElement(By.id("username")).sendKeys("di");
  28. driver.findElement(By.id("password")).sendKeys("di");
  29. driver.findElement(By.id("kc-login")).click();
  30.  
  31. //driver.findElementById("username").sendKeys("di");
  32. //driver.findElementById("password").sendKeys("di");
  33. //driver.findElementById("kc-login").click();
  34. try{
  35. Document doc=Jsoup.connect("http://dev.iff-web.cctv.com/device-manage?projectID=all&subsystemID=all").get();
  36. System.out.println(doc.toString());
  37. }catch (IOException e){
  38. e.printStackTrace();
  39. }
  40. }
  41. }

 运行java应用时,会打开一个浏览器窗口,但窗口会报错:

网上找的方法试了很多,但是还是一直这样。

使用selenium的WebDriver和ChromeDriver实现UI自动化的更多相关文章

  1. WebDriver基本操作入门及UI自动化练手页面

    在这里集中了我们在做UI自动化时常见的一些控件操作.希望能对新手有帮助. 下载地址:http://files.cnblogs.com/zhangfei/demo.rar package com.tes ...

  2. Selenium系列(十七) - Web UI 自动化基础实战(4)

    如果你还想从头学起Selenium,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1680176.html 其次,如果你不懂前端基础知识, ...

  3. appium+python+jenkins+selenium grid+unnittest+生成报告打造UI自动化回归、监控体系

    先放一下截图,展示一下平台做成的样子,以及实现后的结果,后面贴上自动化用例执行的过程中,帮我们发现的线上问题 关于appium自动化环境的安装,网上有很多教程,我就不重复赘述,后面陆续写出设计思想,贴 ...

  4. UI自动化(selenium+python)之浏览器驱动chromedriver安装和配置

    一.安装selenium 前提是已安装Python,python安装 自行百度,这里不概述 安装好python后,cmd打开终端窗口-->pip命令安装 :pip install seleniu ...

  5. 【转】selenium及webdriver的原理

    主要内容转自:http://blog.csdn.net/ant_ren/article/details/7968582和http://blog.csdn.net/ant_ren/article/det ...

  6. selenium及webdriver的原理

    主要内容转自:http://blog.csdn.net/ant_ren/article/details/7968582和http://blog.csdn.net/ant_ren/article/det ...

  7. UI自动化(七)selenium简述

    1.什么是ui自动化模拟人用代码的方式去操作页面2.为什么要做ui自动化后期迭代的时候,老功能比较多,人工维护成本大这时候考虑引入ui自动化3.什么时候做ui自动化项目稳定,不在修改的某些老功能,为这 ...

  8. UI自动化selenium

    1.什么是UI自动化?模拟人用代码的方式去操作页面2.为什么要做UI自动化?后期迭代的时候,老功能比较多,人工维护成本较大,重复性工作较多,这个时候就考虑因为UI自动化3.什么时候做UI自动化?项目稳 ...

  9. Selenium:WebDriver简介及元素定位

    参考内容:官方API文档,下载链接:http://download.csdn.net/detail/kwgkwg001/4004500 虫师:<selenium2自动化测试实战-基于python ...

随机推荐

  1. Jdeveloper下Svn的使用

    Jdeveloper下Svn的使用 官方pdf:jdeveloper使用svn 官方网地址:http://www.oracle.com/technetwork/cn/java/subversion-0 ...

  2. SqlMapConfig.xml配置文件的配置内容

    SqlMapConfig.xml中配置的内容和顺序如下: * properties(属性) * settings(全局配置参数) * typeAliases(类型别名) * typeHandlers( ...

  3. Chrome 强制刷新缓存的方法

    https://jingyan.baidu.com/article/11c17a2c2a9e27f446e39d98.html

  4. python 中numpy的var,std及cov

    var:表示方差, 即各项-均值的平方求和后再除以N , std:表示标准差,是var的平方根. cov:协方差 ,与var类似,但是除以(N-1)

  5. JSON.parse()和JSON.stringify()的使用

    parse用于从一个字符串中解析出json对象,如 var str = '{"name":"huangxiaojian","age":&qu ...

  6. UVa 11136 Hoax or what (STL)

    题意:有 n 天,每天有m个数,开始的前一天没有数据,然后每天从这个里面拿出一个最大的和最小的,求 n 天的最大的和最小的差值相加. 析:一看就知道用set啊,多简单的STL,不过要注意,开long ...

  7. tomcat服务器输入localhost可以访问,ip无法访问解决办法

    最近在开发项目中,遇到的一个问题是: 在 tomcat中发布一个web项目,但是发布成功后,只能用http://localhost:8080/fm访问项目,不能用 http://127.0.0.1:8 ...

  8. OpenGl中的Nurbs B样条曲面的封装的GLU的NURBS的接口

    OpenGl中的Nurbs B样条曲面的封装的GLU的NURBS的接口 创建一个NURBS对象: GLUnurbs* gluNewNurbsRenderer (void); //创建一个NURBS对象 ...

  9. 使用VMWare12.0安装Ubuntu系统

    使用VMWare12.0安装Ubuntu系统 Vmware12的虚拟机的文档说明: http://pubs.vmware.com/workstation-12/index.jsp#com.vmware ...

  10. 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 ...