selenium phantomjs java×××面浏览器环境搭建

java selenium搭建×××面浏览器

1.http://phantomjs.org/

下载windows版phantomjs
selenium phantomjs java×××面浏览器环境搭建

selenium phantomjs java×××面浏览器环境搭建

2.解压后bin目录下会有exe文件
selenium phantomjs java×××面浏览器环境搭建

3.测试代码:

复制代码
package se;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
public class test {

public static void main(String[] args) {
    // TODO Auto-generated method stub
//    System.setProperty("webdriver.gecko.driver", "C:\\Program Files (x86)\\Mozilla Firefox\\geckodriver.exe");
    System.setProperty("phantomjs.binary.path", "C:\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");
//    WebDriver driver = new FirefoxDriver();
    WebDriver driver = new PhantomJSDriver();
    driver.get("http://www.baidu.com");
    System.out.println(driver.getCurrentUrl());

}

}
selenium phantomjs java×××面浏览器环境搭建
4.url成功打印
5.

猜你喜欢

转载自blog.51cto.com/11959730/2136263