TA的每日心情 | 擦汗 前天 09:02 |
---|
签到天数: 1042 天 连续签到: 4 天 [LV.10]测试总司令
|
java selenium搭建无界面浏览器 下载windows版phantomjs 2.解压后bin目录下会有exe文件 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());
-
- }
- }
复制代码4.url成功打印
|
|