本文整理匯總了Java中org.openqa.selenium.remote.DesiredCapabilities.setJavascriptEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java DesiredCapabilities.setJavascriptEnabled方法的具體用法?Java DesiredCapabilities.setJavascriptEnabled怎麽用?Java DesiredCapabilities.setJavascriptEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openqa.selenium.remote.DesiredCapabilities
的用法示例。
在下文中一共展示了DesiredCapabilities.setJavascriptEnabled方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: generatePhantomJsDriver
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
/**
* Generates a phantomJs webdriver.
*
* @return
* A phantomJs webdriver
* @throws TechnicalException
* if an error occured when Webdriver setExecutable to true.
*/
private WebDriver generatePhantomJsDriver() throws TechnicalException {
final String pathWebdriver = DriverFactory.getPath(Driver.PHANTOMJS);
if (!new File(pathWebdriver).setExecutable(true)) {
throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_WEBDRIVER_SET_EXECUTABLE));
}
logger.info("Generating Phantomjs driver ({}) ...", pathWebdriver);
final DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_PAGE_CUSTOMHEADERS_PREFIX + "Accept-Language", "fr-FR");
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, pathWebdriver);
capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
capabilities.setJavascriptEnabled(true);
setLoggingLevel(capabilities);
// Proxy configuration
String proxy = "";
if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
proxy = Context.getProxy().getHttpProxy();
}
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS,
new String[] { "--proxy=" + proxy, "--web-security=no", "--ignore-ssl-errors=true", "--ssl-protocol=tlsv1", "--webdriver-loglevel=NONE" });
return new PhantomJSDriver(capabilities);
}
示例3: generateHtmlUnitDriver
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
/**
* Generates a htmlunit webdriver.
*
* @return
* A htmlunit webdriver
*/
private WebDriver generateHtmlUnitDriver() {
logger.info("Generating HtmlUnit driver...");
final DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit();
capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
capabilities.setJavascriptEnabled(true);
setLoggingLevel(capabilities);
// Proxy configuration
if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
capabilities.setCapability(CapabilityType.PROXY, Context.getProxy());
}
return new HtmlUnitDriver(capabilities);
}
示例4: getFirefoxDriver
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
private static WebDriver getFirefoxDriver(){
/*
Need to have an updated Firefox, but also need
to download and put the geckodriver in your own home dir.
See:
https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
https://github.com/mozilla/geckodriver/releases
However, drivers for FireFox have been often unstable.
Therefore, I do recommend to use Chrome instead
*/
setupDriverExecutable("geckodriver", "webdriver.gecko.driver");
DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
desiredCapabilities.setCapability("marionette", true);
desiredCapabilities.setJavascriptEnabled(true);
return new FirefoxDriver(desiredCapabilities);
}
開發者ID:arcuri82,項目名稱:testing_security_development_enterprise_systems,代碼行數:22,代碼來源:SeleniumTestBase.java
示例5: initIEDriver
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
private WebDriver initIEDriver(String appURL) {
System.out.println("Launching IE browser..");
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setJavascriptEnabled(true);
ieCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS,
true);
ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
ieCapabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING,true);
ieCapabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR,UnexpectedAlertBehaviour.DISMISS); //Accept unexpected alerts
ieCapabilities.setCapability("requireWindowFocus", true);
ieCapabilities.setCapability("enablePersistentHover", false);
ieCapabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
WebDriver driver=new InternetExplorerDriver(ieCapabilities);
driver.manage().deleteAllCookies();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
for(String winHandle : driver.getWindowHandles()){
driver = driver.switchTo().window(winHandle);
}
driver.get(appURL);
return new WebDriverProxy().protect(driver);
}
示例6: generateIEDriver
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
/**
* Generates an ie webdriver. Unable to use it with a proxy. Causes a crash.
*
* @return
* An ie webdriver
* @throws TechnicalException
* if an error occured when Webdriver setExecutable to true.
*/
private WebDriver generateIEDriver() throws TechnicalException {
final String pathWebdriver = DriverFactory.getPath(Driver.IE);
if (!new File(pathWebdriver).setExecutable(true)) {
throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_WEBDRIVER_SET_EXECUTABLE));
}
logger.info("Generating IE driver ({}) ...", pathWebdriver);
System.setProperty(Driver.IE.getDriverName(), pathWebdriver);
final DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
capabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
capabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true);
capabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);
capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capabilities.setCapability("disable-popup-blocking", true);
capabilities.setJavascriptEnabled(true);
setLoggingLevel(capabilities);
// Proxy configuration
if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
capabilities.setCapability(CapabilityType.PROXY, Context.getProxy());
}
return new InternetExplorerDriver(capabilities);
}
示例7: createBrowserSession
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
private static WebDriver createBrowserSession() throws MalformedURLException {
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setJavascriptEnabled(true);
LoggingPreferences logPreferences = new LoggingPreferences();
logPreferences.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPreferences);
return new RemoteWebDriver(
new URL("http://" + runtime.getContainer("selenium-chrome").getIp() + ":4444/wd/hub"),
capabilities
);
}
示例8: getDefaultDesiredCapabilities
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
public static DesiredCapabilities getDefaultDesiredCapabilities() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
capabilities.setCapability("acceptSslCerts", true);
capabilities.setCapability("takesScreenshot", true);
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, asList("--ignore-ssl-errors=true"));
LoggingPreferences loggingPreferences = new LoggingPreferences();
loggingPreferences.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, loggingPreferences);
return capabilities;
}
示例9: getChromeCapabilities
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
public static DesiredCapabilities getChromeCapabilities() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
capabilities.setCapability("acceptSslCerts", true);
capabilities.setCapability("takesScreenshot", true);
capabilities.setCapability(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, asList("--ignore-ssl-errors=true"));
LoggingPreferences loggingPreferences = new LoggingPreferences();
loggingPreferences.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, loggingPreferences);
return capabilities;
}
示例10: supportsJavascriptEnabledCapability
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
public void supportsJavascriptEnabledCapability() throws Throwable {
DesiredCapabilities caps = new DesiredCapabilities("java", "1.0", Platform.getCurrent());
caps.setJavascriptEnabled(true);
driver = new JavaDriver(caps, caps);
}
示例11: addDesiredCapabilities
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
@Override
public void addDesiredCapabilities(DesiredCapabilities desiredCapabilities) {
desiredCapabilities.setCapability("applicationCacheEnabled", false);
desiredCapabilities.setJavascriptEnabled(true);
desiredCapabilities.setBrowserName("firefox");
}
示例12: createPhantomJsDesiredCapabilities
import org.openqa.selenium.remote.DesiredCapabilities; //導入方法依賴的package包/類
public DesiredCapabilities createPhantomJsDesiredCapabilities(SiteConfig siteConfig, DriverConfig driverConfig) {
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
capabilities.setJavascriptEnabled(true);
return capabilities;
}