本文整理匯總了Java中org.openqa.selenium.remote.DesiredCapabilities.phantomjs方法的典型用法代碼示例。如果您正苦於以下問題:Java DesiredCapabilities.phantomjs方法的具體用法?Java DesiredCapabilities.phantomjs怎麽用?Java DesiredCapabilities.phantomjs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openqa.selenium.remote.DesiredCapabilities
的用法示例。
在下文中一共展示了DesiredCapabilities.phantomjs方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createPhantomJSDriver
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
private static WebDriver createPhantomJSDriver(String driverPath) {
DesiredCapabilities desiredCapabilities = DesiredCapabilities.phantomjs();
desiredCapabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, driverPath);
desiredCapabilities.setCapability(CapabilityType.ELEMENT_SCROLL_BEHAVIOR, true);
desiredCapabilities.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
desiredCapabilities.setCapability(CapabilityType.ENABLE_PROFILING_CAPABILITY, true);
desiredCapabilities.setCapability(CapabilityType.HAS_NATIVE_EVENTS, true);
desiredCapabilities.setJavascriptEnabled(true);
ArrayList<String> cliArgs = new ArrayList<String>();
cliArgs.add("--web-security=true");
cliArgs.add("--ignore-ssl-errors=true");
desiredCapabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgs);
return new PhantomJSDriver(desiredCapabilities);
}
示例2: createWebDriver
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
private WebDriver createWebDriver(final Consumer<DesiredCapabilities> desiredCapabilities) {
String hostName = GhostDriverService.get().getHostName();
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
if (desiredCapabilities != null) {
desiredCapabilities.accept(capabilities);
}
try {
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:" + GhostDriverService.get().getLocalPort() + "/"), capabilities);
driver.manage().window().setSize(new Dimension(1920, 1080));
return driver;
} catch (MalformedURLException e) {
throw new IllegalStateException("Wrong hostName '" + hostName + "', possibly GhostDriverService::start not called ", e);
}
}
示例3: PhantomJSFetcher
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
private PhantomJSFetcher(String phantomJsBinaryPath, int timeout, boolean loadImages, String userAgent, Collection<Cookie> cookies) {
System.setProperty("phantomjs.binary.path", phantomJsBinaryPath);
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
capabilities.setCapability("phantomjs.page.settings.resourceTimeout", timeout);
capabilities.setCapability("phantomjs.page.settings.loadImages", loadImages);
capabilities.setCapability("phantomjs.page.settings.userAgent", userAgent);
this.webDriver = new PhantomJSDriver(capabilities);
this.userAgent = userAgent;
this.cookies = cookies;
}
示例4: PhantomJSProcessor
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
private PhantomJSProcessor(String phantomJsBinaryPath, int timeout, boolean loadImages, String userAgent, Extractor<WebDriver, ?> handler, TaskFilter filter) {
System.setProperty("phantomjs.binary.path", phantomJsBinaryPath);
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
capabilities.setCapability("phantomjs.page.settings.resourceTimeout", timeout);
capabilities.setCapability("phantomjs.page.settings.loadImages", loadImages);
capabilities.setCapability("phantomjs.page.settings.userAgent", userAgent);
this.webDriver = new PhantomJSDriver(capabilities);
this.handler = handler;
this.filter = filter;
}
示例5: prepareDriver
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
/**
* Create the driver instance
*/
@Override
protected void prepareDriver() throws Exception {
if (!isLocalTest()) {
capability = DesiredCapabilities.phantomjs();
}
super.prepareDriver();
}
示例6: SeleniumGridParallelITCase
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
public SeleniumGridParallelITCase() {
// Add phantomjs in test
super.repeatedCapabilities = new DesiredCapabilities[] { DesiredCapabilities.phantomjs(), DesiredCapabilities.phantomjs() };
}
示例7: SeleniumGridSequentialITCase
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
public SeleniumGridSequentialITCase() {
// Add phantomjs in test
super.repeatedCapabilities = new DesiredCapabilities[] { DesiredCapabilities.phantomjs(), DesiredCapabilities.phantomjs() };
}
示例8: createPhantomJsDesiredCapabilities
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
public DesiredCapabilities createPhantomJsDesiredCapabilities(SiteConfig siteConfig, DriverConfig driverConfig) {
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
capabilities.setJavascriptEnabled(true);
return capabilities;
}