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浏览器

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

  • 相关阅读:
    SpringBoot(一)_快速实战搭建项目
    maven入门 (二)_私服安装与上传下载
    maven入门(一)
    Ionic 2 开发(一)_安装与目录结构
    echarts添加点击事件
    win下 git gui 使用教程
    安装centos6.3
    PAT甲级题分类汇编——图
    PAT甲级题分类汇编——树
    PAT甲级题分类汇编——理论
  • 原文地址:https://www.cnblogs.com/xiaobaibailongma/p/12297593.html
Copyright © 2011-2022 走看看