本文整理汇总了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;
}