码迷,mamicode.com
首页 > 其他好文 > 详细

Selenium之firefox浏览器的启动

时间:2018-03-30 00:13:05      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:.exe   .com   drive   tor   实例   creat   地址栏   stat   url   

1、编写如下代码

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

/**
 * Created by Administrator on 2018/3/29 0029.
 */
public class FirefoxTest {
    public static void main(String[] args){
        WebDriver driver;
        //启动找不到firefox才需要设置
        System.setProperty("webdriver.firefox.bin","D:\\ztsoft\\Firefox\\firefox.exe");
        //实例化一个对象firefox
        driver =  new FirefoxDriver();
        String testUrl = "http://www.baidu.com";
        driver.get(testUrl);
        driver.quit();
    }

2、执行代码,弹出firefox,地址栏输入代码设置的地址。

Selenium之firefox浏览器的启动

标签:.exe   .com   drive   tor   实例   creat   地址栏   stat   url   

原文地址:https://www.cnblogs.com/biyuting/p/8673215.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!