List of usage examples for org.openqa.selenium.remote CapabilityType UNEXPECTED_ALERT_BEHAVIOUR
String UNEXPECTED_ALERT_BEHAVIOUR
To view the source code for org.openqa.selenium.remote CapabilityType UNEXPECTED_ALERT_BEHAVIOUR.
Click Source Link
From source file:com.partnet.automation.selenium.AbstractConfigurableDriverProvider.java
License:Apache License
/** * Best found default capabilities for Internet Explorer * //from w w w . j a v a 2 s .c om * @return {@link DesiredCapabilities} */ protected DesiredCapabilities getInternetExplorerCapabilities() { final DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); // get past certificate security warning pages capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); // setup native events and window focus // http://jimevansmusic.blogspot.com/2012/06/whats-wrong-with-internet-explorer.html capabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS, true); capabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true); // don't accept alerts automatically capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, false); return capabilities; }
From source file:com.redspr.redrobot.WebDriverRobot.java
License:Open Source License
public WebDriverRobot() { DesiredCapabilities dc = DesiredCapabilities.firefox(); dc.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE); WebDriver ff = new FirefoxDriver(dc); init(ff);//w w w .j av a2s . c om }
From source file:io.openvidu.test.browsers.FirefoxUser.java
License:Apache License
public FirefoxUser(String userName, int timeOfWaitInSeconds) { super(userName, timeOfWaitInSeconds); DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setAcceptInsecureCerts(true); capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE); FirefoxProfile profile = new FirefoxProfile(); // This flag avoids granting the access to the camera profile.setPreference("media.navigator.permission.disabled", true); // This flag force to use fake user media (synthetic video of multiple color) profile.setPreference("media.navigator.streams.fake", true); capabilities.setCapability(FirefoxDriver.PROFILE, profile); String REMOTE_URL = System.getProperty("REMOTE_URL_FIREFOX"); if (REMOTE_URL != null) { log.info("Using URL {} to connect to remote web driver", REMOTE_URL); try {/*from w ww . jav a 2 s . com*/ this.driver = new RemoteWebDriver(new URL(REMOTE_URL), capabilities); } catch (MalformedURLException e) { e.printStackTrace(); } } else { log.info("Using local web driver"); this.driver = new FirefoxDriver(capabilities); } this.configureDriver(); }
From source file:mbaf.galileoprojselenium.WebDriver.WebDriverGC.java
@Override public ChromeDriver getWebDriver() { DesiredCapabilities dc = new DesiredCapabilities(); dc.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE); System.setProperty("webdriver.chrome.driver", "chromedriver.exe"); return new ChromeDriver(dc); }
From source file:org.safs.selenium.webdriver.lib.SelectBrowser.java
License:Open Source License
/** * //from w w w . j a va 2 s . c o m * @param browserName String, the browser name, such as "explorer" * @param extraParameters Map<String,Object>, can be used to pass more browser parameters, such as proxy settings. * @return DesiredCapabilities */ public static DesiredCapabilities getDesiredCapabilities(String browserName, Map<String, Object> extraParameters) { String debugmsg = StringUtils.debugmsg(false); DesiredCapabilities caps = null; if (browserName.equals(BROWSER_NAME_IE)) { System.setProperty(SYSTEM_PROPERTY_WEBDRIVER_IE, "IEDriverServer.exe"); caps = DesiredCapabilities.internetExplorer(); caps.setCapability("nativeEvents", true); caps.setCapability("requireWindowFocus", true); //caps.setCapability("browserName", BROWSER_NAME_IE); } else if (browserName.equals(BROWSER_NAME_CHROME)) { System.setProperty(SYSTEM_PROPERTY_WEBDRIVER_CHROME, "chromedriver.exe"); caps = DesiredCapabilities.chrome(); // Disable extensions to avoid popping up 'Disable developer mode extensions' message by default. if (!extraParameters.containsKey(KEY_CHROME_DISABLE_EXTENSIONS)) { // Only execute if no user's setting extraParameters.put(KEY_CHROME_DISABLE_EXTENSIONS, "true"); } //caps.setCapability("browserName", BROWSER_NAME_CHROME); } else if (browserName.equals(BROWSER_NAME_EDGE)) { System.setProperty(SYSTEM_PROPERTY_WEBDRIVER_EDGE, "MicrosoftWebDriver.exe"); caps = DesiredCapabilities.edge(); //caps.setCapability("browserName", BROWSER_NAME_EDGE); } else if (browserName.equals(BROWSER_NAME_ANDROID_CHROME)) { System.setProperty(SYSTEM_PROPERTY_WEBDRIVER_CHROME, "chromedriver.exe"); caps = DesiredCapabilities.chrome(); ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setExperimentalOption("androidPackage", "com.android.chrome"); caps.setCapability(ChromeOptions.CAPABILITY, chromeOptions); caps.setCapability(CapabilityType.BROWSER_NAME, BROWSER_NAME_CHROME); } else if (browserName.equals(BROWSER_NAME_IPAD_SIMULATOR_SAFARI)) { caps = new DesiredCapabilities(); caps.setCapability("device", "ipad"); caps.setCapability("simulator", "true"); caps.setCapability(CapabilityType.BROWSER_NAME, "safari"); } else { // default browser always caps = DesiredCapabilities.firefox(); caps.setCapability(CapabilityType.BROWSER_NAME, BROWSER_NAME_FIREFOX); } String unexpectedAlertBehaviour = Processor.getUnexpectedAlertBehaviour(); if (unexpectedAlertBehaviour == null) unexpectedAlertBehaviour = System .getProperty(DriverConstant.PROERTY_SAFS_TEST_UNEXPECTEDALERTBEHAVIOUR); if (unexpectedAlertBehaviour != null) { IndependantLog.debug(debugmsg + " Set '" + unexpectedAlertBehaviour + "' to '" + CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR + "'."); caps.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, unexpectedAlertBehaviour); } if (extraParameters != null && !extraParameters.isEmpty()) { //1. Add http proxy settings to Capabilities, if they exist Object proxysetting = extraParameters.get(KEY_PROXY_SETTING); if (proxysetting != null && proxysetting instanceof String) { org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy(); proxy.setHttpProxy(proxysetting.toString()); Object bypass = extraParameters.get(KEY_PROXY_BYPASS_ADDRESS); if (bypass != null && bypass instanceof String) { proxy.setNoProxy(bypass.toString()); } caps.setCapability(CapabilityType.PROXY, proxy); } //2 Add firefox profile setting to Capabilities. if (BROWSER_NAME_FIREFOX.equals(browserName)) { //2.1 Add firefox profile setting to Capabilities, if it exists FirefoxProfile firefoxProfile = null; Object firefoxProfileParam = extraParameters.get(KEY_FIREFOX_PROFILE); if (firefoxProfileParam != null && firefoxProfileParam instanceof String) { //Can be profile's name or profile's file name String profileNameOrPath = firefoxProfileParam.toString(); IndependantLog.debug( debugmsg + "Try to Set firefox profile '" + profileNameOrPath + "' to Capabilities."); firefoxProfile = getFirefoxProfile(profileNameOrPath); if (firefoxProfile != null) { caps.setCapability(KEY_FIREFOX_PROFILE, profileNameOrPath);//used to store in session file } else { IndependantLog.error(debugmsg + " Fail to set firefox profile to Capabilities."); } } //2.2 Add firefox profile preferences to Capabilities, if it exists Object prefsFileParam = extraParameters.get(KEY_FIREFOX_PROFILE_PREFERENCE); if (prefsFileParam != null && prefsFileParam instanceof String) { String preferenceFile = prefsFileParam.toString(); IndependantLog.debug(debugmsg + "Try to Set firefox preference file '" + preferenceFile + "' to Firefox Profile."); caps.setCapability(KEY_FIREFOX_PROFILE_PREFERENCE, preferenceFile);//used to store in session file Map<?, ?> firefoxPreference = Json.readJSONFileUTF8(preferenceFile); if (firefoxProfile == null) firefoxProfile = new FirefoxProfile(); addFireFoxPreference(firefoxProfile, firefoxPreference); } if (firefoxProfile != null) { caps.setCapability(FirefoxDriver.PROFILE, firefoxProfile); } } //3. Add chrome-options-settings to Capabilities. if (BROWSER_NAME_CHROME.equals(browserName) || BROWSER_NAME_ANDROID_CHROME.equals(browserName)) { setChromeCapabilities(caps, extraParameters); } //put extra grid-nodes information Object gridnodes = extraParameters.get(KEY_GRID_NODES_SETTING); if (gridnodes != null && gridnodes instanceof String) { caps.setCapability(KEY_GRID_NODES_SETTING, gridnodes); } } return caps; }