package com.dong.Selenium;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
public class PhantomjsTest {
private static final String INDEX_URL = "https://www.gslltd.com.hk/";
public static void main(String[] args) {
DesiredCapabilities dcsps = new DesiredCapabilities();//配置文件
dcsps.setCapability("acceptSslCerts", true);
dcsps.setCapability("takesScreenshot", true);
dcsps.setCapability("cssSelectorsEnabled", true);
dcsps.setJavascriptEnabled(true);//支持js
//设置phantomJS路径
dcsps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "D:\\aaMARK\\phantomjs-2.0.0-windows\\bin\\phantomjs.exe");
PhantomJSDriver driver = new PhantomJSDriver(dcsps);
driver.get(INDEX_URL);
System.out.println(driver.getPageSource());
}
}
Selenium+phantomJS
最新推荐文章于 2024-05-21 16:15:16 发布