selenium phantomjs

	public static WebDriver createWebDriver() {
		capability = DesiredCapabilities.phantomjs();
		capability.setJavascriptEnabled(false);
		FirefoxProfile profile = new FirefoxProfile();
		// 去掉css
		profile.setPreference("permissions.default.stylesheet", 2);
		// 去掉图片
		profile.setPreference("permissions.default.image", 2);
		// 去掉flash
		profile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so",
				false);
		System.setProperty("phantomjs.binary.path",
				"E:\\test\\phantomjs-1.9.7-windows\\phantomjs.exe");
		// WebDriver ff = new HtmlUnitDriver(cc);
		WebDriver ff = new PhantomJSDriver(capability);
		// WebDriver ff= new Ph
		return ff;
	}

   <dependency>
    <groupId>com.github.detro.ghostdriver</groupId>
    <artifactId>phantomjsdriver</artifactId>
    <version>1.1.0</version>
</dependency>

你可能感兴趣的:(selenium phantomjs)