[Selenium] 使用Firefox Driver 示例

//导入Selenium 库和FirefoxDriver 库

package com.learningselenium.simplewebdriver;

import org.openqa.selenium.*;

import org.openqa.selenium.firefox.FirefoxDriver;

public class testFirefoxDriver(){

  public static main(String[] args){

    WebDriver driver = new FirefoxDriver(); //启用FirefoxDriver

    driver.get("http://www.baidu.com"); //讲在Firefox 浏览器中打开百度主页

    //讲获取当前页面的URL地址并存储在变量url 中。如果相同的操作需要在Selenium IDE 中完成,那么需要通过storeLocation 命令来完成

    String url = driver.getCurrentUrl(); 

    System.out.println(url);

    driver.close();

  }

}

原文地址:https://www.cnblogs.com/feifeidxl/p/4538591.html