zoukankan      html  css  js  c++  java
  • java+selenium+new——4种主流浏览器加载

    IE浏览器


    import org.openqa.selenium.ie.InternetExplorerDriver;


    System.setProperty("webdriver.ie.driver","D:\\IEDriverServer.exe");

    driver = new InternetExplorerDriver();

    driver.get("http://www.baidu.com");


    ====================================================================================

    Firefox浏览器

    import org.openqa.selenium.firefox.FirefoxDriver;

    System.setProperty("webdriver.firefox.bin","C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); //设置火狐的安装路径,防止系统找不到

    System.setProperty("webdriver.gecko.driver","D:\\geckodriver.exe"); //有些环境之下无需使用此语句

    FirefoxDriver driver = new FirefoxDriver(); //初始化FireFox浏览器实例,并打开浏览器

    driver.get("https://www.baidu.com");

    ====================================================================================================

    Chrome浏览器

    import org.openqa.selenium.chrome.ChromeDriver;


    System.setProperty("webdriver.chrome.driver","D:\\chromedriver.exe");

    driver = new ChromeDriver();

    driver.get("http://www.baidu.com");


    ====================================================================================================

    Safari浏览器


    import org.openqa.selenium.safari.SafariDriver;

    driver.get("http://www.baidu.com"); //直接使用,因为一般苹果系统里都会默认按照Safari浏览器

    ====================================================================================================

  • 相关阅读:
    JAVA 分布式
    Spring Boot -01- 快速入门篇(图文教程)
    MyBatis -01- 初识 MyBatis + MyBatis 环境搭建
    Vue 框架-12-Vue 项目的详细开发流程
    Vue 框架-11-介绍src文件流程及根组件app+HBuilder 配置
    Vue 框架-10-搭建脚手架 CLI
    LeetCode
    LeetCode
    LeetCode
    LeetCode
  • 原文地址:https://www.cnblogs.com/xiaobaibailongma/p/12297593.html
Copyright © 2011-2022 走看看