zoukankan      html  css  js  c++  java
  • Java + Selenium 系列之浏览器类型选择工具类

    目前做Web自动化常用的浏览器有谷歌、火狐、IE,本文介绍封装该三种浏览器的类

    一、条件

    1、Maven项目需要在pox.xml文件中添加selenium依赖

    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.141.59</version>
    </dependency>

    2、需要下载各个浏览器版本对应的驱动,放入资源文件夹中

     1)谷歌版本对应驱动版本

     

    chrome浏览器各版本:http://www.chromedownloads.net/chrome64win/

    Selenium镜像:http://npm.taobao.org/mirrors/selenium

    2)火狐版本对应驱动版本

     

    Firefox驱动:https://github.com/mozilla/geckodriver/releases/
    Firefox各版本:http://ftp.mozilla.org/pub/firefox/releases/

    二、 浏览器类封装

    在实际的测试类中, 只需要传入对应的浏览器类型就可以了,如BrowserUtil.openBrowser("chrome");

     

     

  • 相关阅读:
    Windows下MySQL多实例运行
    Java中,什么时候用logger.debuge,info,error
    乒乓球(Table Tennis)
    [Delphi]Delphi学习
    [CALL]01
    [转自看雪]新手学习计划
    [JAVA]函数
    [1.1]
    [SQL]课堂记录
    [SYS]VS2010驱动开发配置
  • 原文地址:https://www.cnblogs.com/wanshuang/p/12511208.html
Copyright © 2011-2022 走看看