List of usage examples for org.openqa.selenium.edge EdgeDriver EdgeDriver
@Deprecated
public EdgeDriver(Capabilities capabilities)
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
/** * This method build a webDriver based on the passed in browser request * * @param browser/*from w ww .ja v a 2 s .c o m*/ * @return WebDriver * @throws MalformedURLException */ private static WebDriver buildWebDriver(String browserName) { DesiredCapabilities capability = null; BrowserType browserType = BrowserType.getBrowserTypeFromString(browserName); switch (browserType) { case MARIONETTE: FirefoxProfile ffProfile = null; ffProfile = new FirefoxProfile(); ffProfile.setAcceptUntrustedCertificates(true); ffProfile.setAssumeUntrustedCertificateIssuer(false); DesiredCapabilities cap = DesiredCapabilities.firefox(); cap.setCapability("marionette", true); cap.setCapability("firefox_profile", ffProfile); cap.setCapability("handlesAlerts", true); sysEnv = System.getenv("webdriver.firefox.marionette"); if (sysEnv == null) { sysEnv = findFileName("C:/apps/selenium", "geckodriver.exe", FileSearchType.File); if (sysEnv == null) { log.info( "Please set the webdriver.firefox.marionette in system environment variables and restart the PC OR copy all your webdrivers under 'C:/selenium' location"); throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName); } else { System.setProperty("webdriver.firefox.marionette", sysEnv); } } return new MarionetteDriver(capability); case FIREFOX_DRIVER: capability = DesiredCapabilities.firefox(); FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setAcceptUntrustedCertificates(true); firefoxProfile.setEnableNativeEvents(true); firefoxProfile.setAssumeUntrustedCertificateIssuer(true); capability.setCapability(FirefoxDriver.PROFILE, firefoxProfile); return new FirefoxDriver(capability); case CHROME_DRIVER: sysEnv = System.getenv("webdriver.chrome.driver"); if (sysEnv == null) { sysEnv = findFileName("C:/apps/selenium", "chromedriver.exe", FileSearchType.File); if (sysEnv == null) { log.info( "Please set the webdriver.chrome.driver in system environment variables and restart the PC OR copy all your webdrivers under 'C:/selenium' location"); throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName); } else { System.setProperty("webdriver.chrome.driver", sysEnv); } } capability = DesiredCapabilities.chrome(); ChromeOptions options = new ChromeOptions(); options.addArguments(new String[] { "--allow-running-insecure-content" }); options.addArguments(new String[] { "--ignore-certificate-errors" }); options.addArguments(new String[] { "--enable-npapi" }); options.addArguments(new String[] { "--disable-extensions" }); options.addArguments(new String[] { "--start-maximized" }); capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); capability.setCapability(ChromeOptions.CAPABILITY, options); return new ChromeDriver(capability); case INTERNET_EXPLORER: sysEnv = System.getenv("webdriver.ie.driver"); if (sysEnv == null) { sysEnv = findFileName("C:/apps/selenium", "IEDriverServer.exe", FileSearchType.File); if (sysEnv == null) { log.info( "Please set the webdriver.ie.driver in system environment variables and restart the PC"); throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName); } else { System.setProperty("webdriver.ie.driver", sysEnv); } } capability = DesiredCapabilities.internetExplorer(); capability.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); capability.setCapability("ignoreProtectedModeSettings", true); capability.setCapability("acceptSslCerts", true); capability.setCapability("ignoreZoomSetting", true); capability.setCapability("nativeEvents", true); capability.setCapability("ie.ensureCleanSession", true); return new InternetExplorerDriver(capability); case SAFARI: capability = DesiredCapabilities.safari(); capability.setCapability("acceptSslCerts", true); capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); capability.setCapability("ensureCleanSession", true); capability.setJavascriptEnabled(true); return new SafariDriver(capability); /* case OPERA_DRIVER: capability = DesiredCapabilities.opera(); capability.setCapability("opera.host", "127.0.0.1"); return new OperaDriver(); */ case EDGE: capability = DesiredCapabilities.edge(); EdgeOptions option = new EdgeOptions(); capability.setCapability("edgeOptions", option); return new EdgeDriver(capability); default: log.info( "Currenty support is there for Chrome, Firefox, Firefox Marionette, Internet Explorer, Edge, Safari & Opera. Support is not there for " + browserName); capability = DesiredCapabilities.firefox(); FirefoxProfile firefoxProf = new FirefoxProfile(); firefoxProf.setAcceptUntrustedCertificates(true); firefoxProf.setEnableNativeEvents(true); firefoxProf.setAssumeUntrustedCertificateIssuer(true); capability.setCapability(FirefoxDriver.PROFILE, firefoxProf); return new FirefoxDriver(capability); } }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
/** * This method build a RemoteWebDriver based on the passed in browser request * * @param browser//from w w w.j a v a 2 s. co m * @return RemoteWebDriver * */ private static RemoteWebDriver buildRemoteWebDriver(String browserName) { DesiredCapabilities capability = null; BrowserType browserType = BrowserType.getBrowserTypeFromString(browserName); switch (browserType) { case MARIONETTE: FirefoxProfile ffProfile = null; ffProfile = new FirefoxProfile(); ffProfile.setAcceptUntrustedCertificates(true); ffProfile.setAssumeUntrustedCertificateIssuer(false); DesiredCapabilities cap = DesiredCapabilities.firefox(); cap.setCapability("marionette", true); cap.setCapability("firefox_profile", ffProfile); cap.setCapability("handlesAlerts", true); sysEnv = System.getenv("webdriver.firefox.marionette"); if (sysEnv == null) { sysEnv = findFileName("C:/apps/selenium", "geckodriver.exe", FileSearchType.File); if (sysEnv == null) { log.info( "Please set the webdriver.firefox.marionette in system environment variables and restart the PC OR copy all your webdrivers under 'C:/selenium' location"); throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName); } else { System.setProperty("webdriver.firefox.marionette", sysEnv); } } return new MarionetteDriver(capability); case FIREFOX_DRIVER: capability = DesiredCapabilities.firefox(); FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setAcceptUntrustedCertificates(true); firefoxProfile.setEnableNativeEvents(true); capability.setCapability(FirefoxDriver.PROFILE, firefoxProfile); capability.setPlatform(capability.getPlatform()); capability.setVersion(capability.getVersion()); return new FirefoxDriver(capability); case CHROME_DRIVER: sysEnv = System.getenv("webdriver.chrome.driver"); if (sysEnv == null) { sysEnv = findFileName("C:/apps/selenium", "chromedriver.exe", FileSearchType.File); if (sysEnv == null) { log.info( "Please set the webdriver.chrome.driver in system environment variables and restart the PC OR copy all your webdrivers under 'C:/selenium' location"); throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName); } else { System.setProperty("webdriver.chrome.driver", sysEnv); } } capability = DesiredCapabilities.chrome(); ChromeOptions options = new ChromeOptions(); options.addArguments(new String[] { "--allow-running-insecure-content" }); options.addArguments(new String[] { "--ignore-certificate-errors" }); options.addArguments(new String[] { "--enable-npapi" }); options.addArguments(new String[] { "--disable-extensions" }); options.addArguments(new String[] { "--start-maximized" }); capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); capability.setCapability(ChromeOptions.CAPABILITY, options); capability.setPlatform(capability.getPlatform()); capability.setVersion(capability.getVersion()); return new ChromeDriver(capability); case INTERNET_EXPLORER: sysEnv = System.getenv("webdriver.ie.driver"); if (sysEnv == null) { sysEnv = findFileName("C:/apps/selenium", "IEDriverServer.exe", FileSearchType.File); if (sysEnv == null) { log.info( "Please set the webdriver.ie.driver in system environment variables and restart the PC"); throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName); } else { System.setProperty("webdriver.ie.driver", sysEnv); } } capability = DesiredCapabilities.internetExplorer(); capability.setCapability("ignoreProtectedModeSettings", true); String browserVersion = capability.getVersion(); if (browserVersion != null && browserVersion.equals("10")) { capability.setPlatform(Platform.WINDOWS); capability.setVersion(browserVersion); } else if (browserVersion != null && browserVersion.equals("11")) { capability.setPlatform(Platform.WIN8_1); capability.setVersion(browserVersion); } capability.setBrowserName("internet explorer"); capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); return new InternetExplorerDriver(capability); case SAFARI: capability = DesiredCapabilities.safari(); capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); capability.setCapability("ensureCleanSession", true); capability.setPlatform(capability.getPlatform()); capability.setVersion(null); return new SafariDriver(capability); /* case OPERA_DRIVER: capability = DesiredCapabilities.opera(); capability.setCapability("opera.profile", "/test"); return new OperaDriver(); */ case EDGE: capability = DesiredCapabilities.edge(); EdgeOptions option = new EdgeOptions(); capability.setCapability("edgeOptions", option); return new EdgeDriver(capability); default: log.info( "Currenty support is there for Chrome, Firefox, Firefox Marionette, Internet Explorer, Edge, Safari & Opera. Support is not there for " + browserName); capability = DesiredCapabilities.firefox(); firefoxProfile = new FirefoxProfile(); firefoxProfile.setAcceptUntrustedCertificates(true); firefoxProfile.setEnableNativeEvents(true); capability.setCapability(FirefoxDriver.PROFILE, firefoxProfile); capability.setPlatform(capability.getPlatform()); capability.setVersion(capability.getVersion()); return new FirefoxDriver(capability); } }
From source file:com.seleniumtests.browserfactory.EdgeDriverFactory.java
License:Apache License
/** * create native driver instance, designed for unit testing. * * @return the driver// w ww . j av a 2s. c o m */ @Override protected WebDriver createNativeDriver() { return new EdgeDriver((EdgeOptions) driverOptions); }
From source file:contentspeededgedriver.ContentSpeedEdgeDriver.java
public static void main(String[] args) { try {//from w w w. j a v a2 s.c o m System.setProperty("webdriver.edge.driver", "D:\\Documentatie\\Selenium\\MicrosoftWebDriver.exe"); DesiredCapabilities capabilities = DesiredCapabilities.edge(); capabilities.setCapability(CapabilityType.SUPPORTS_APPLICATION_CACHE, false); LoggingPreferences logPrefs = new LoggingPreferences(); logPrefs.enable(LogType.BROWSER, Level.ALL); logPrefs.enable(LogType.CLIENT, Level.ALL); logPrefs.enable(LogType.DRIVER, Level.ALL); logPrefs.enable(LogType.SERVER, Level.ALL); logPrefs.enable(LogType.PERFORMANCE, Level.ALL); capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); capabilities.setCapability("browser", "Edge"); capabilities.setCapability("acceptSslCerts", true); capabilities.setCapability(CapabilityType.PAGE_LOAD_STRATEGY, "eager"); capabilities.setCapability("os", "Windows"); capabilities.setCapability("os_version", "10"); driver = new EdgeDriver(capabilities); driver.manage().window().maximize(); // driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.get( "https://www.armonianaturii.ro/ceaiuri-naturale/ceaiuri-medicinale-simple/ceai-conuri-de-hamei-50g-plafar-plaf-00025.html"); objProdus = new ProdusCeai(driver); objProdus.Actions(); driver.quit(); } catch (WebDriverException ex) { ex.printStackTrace(); driver.quit(); } }
From source file:io.ddavison.conductor.Locomotive.java
License:Open Source License
public Locomotive() { final Properties props = new Properties(); try {/*from ww w. j a v a 2s . c o m*/ props.load(getClass().getResourceAsStream("/default.properties")); } catch (IOException e) { logFatal("Couldn't load in default properties"); } catch (Exception e) { } /** * Order of overrides: * <ol> * <li>Test</li> * <li>JVM Arguments</li> * <li>Default properties</li> * </ol> */ final Config testConfiguration = getClass().getAnnotation(Config.class); configuration = new LocomotiveConfig(testConfiguration, props); DesiredCapabilities capabilities; Capabilities extraCapabilities; try { extraCapabilities = configuration.capabilities().newInstance(); } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); logFatal(e.getMessage()); System.exit(1); return; } baseUrl = configuration.url(); log.debug(String.format( "\n=== Configuration ===\n" + "\tURL: %s\n" + "\tBrowser: %s\n" + "\tHub: %s\n" + "\tBase url: %s\n", configuration.url(), configuration.browser().moniker, configuration.hub(), configuration.baseUrl())); boolean isLocal = StringUtils.isEmpty(configuration.hub()); switch (configuration.browser()) { case CHROME: capabilities = DesiredCapabilities.chrome(); capabilities.merge(extraCapabilities); if (isLocal) try { driver = new ChromeDriver(capabilities); } catch (Exception x) { x.printStackTrace(); logFatal( "Also see https://github.com/conductor-framework/conductor/wiki/WebDriver-Executables"); System.exit(1); } break; case FIREFOX: capabilities = DesiredCapabilities.firefox(); capabilities.merge(extraCapabilities); if (isLocal) try { driver = new FirefoxDriver(capabilities); } catch (Exception x) { x.printStackTrace(); logFatal( "Also see https://github.com/conductor-framework/conductor/wiki/WebDriver-Executables"); System.exit(1); } break; case INTERNET_EXPLORER: capabilities = DesiredCapabilities.internetExplorer(); capabilities.merge(extraCapabilities); if (isLocal) try { driver = new InternetExplorerDriver(capabilities); } catch (Exception x) { x.printStackTrace(); logFatal( "Also see https://github.com/conductor-framework/conductor/wiki/WebDriver-Executables"); System.exit(1); } break; case EDGE: capabilities = DesiredCapabilities.edge(); capabilities.merge(extraCapabilities); if (isLocal) try { driver = new EdgeDriver(capabilities); } catch (Exception x) { x.printStackTrace(); logFatal( "Also see https://github.com/conductor-framework/conductor/wiki/WebDriver-Executables"); System.exit(1); } break; case SAFARI: capabilities = DesiredCapabilities.safari(); capabilities.merge(extraCapabilities); if (isLocal) try { driver = new SafariDriver(capabilities); } catch (Exception x) { x.printStackTrace(); logFatal( "Also see https://github.com/conductor-framework/conductor/wiki/WebDriver-Executables"); System.exit(1); } break; case PHANTOMJS: capabilities = DesiredCapabilities.phantomjs(); capabilities.merge(extraCapabilities); if (isLocal) try { driver = new PhantomJSDriver(capabilities); } catch (Exception x) { x.printStackTrace(); logFatal( "Also see https://github.com/conductor-framework/conductor/wiki/WebDriver-Executables"); System.exit(1); } break; default: System.err.println("Unknown browser: " + configuration.browser()); return; } if (!isLocal) // they are using a hub. try { capabilities.merge(extraCapabilities); driver = new RemoteWebDriver(new URL(configuration.hub()), capabilities); // just override the driver. } catch (Exception x) { logFatal("Couldn't connect to hub: " + configuration.hub()); x.printStackTrace(); return; } actions = new Actions(driver); if (StringUtils.isNotEmpty(baseUrl)) driver.navigate().to(baseUrl); }
From source file:io.github.seleniumquery.browser.driver.builders.EdgeDriverBuilder.java
License:Apache License
private WebDriver buildEdge() { try {/*from ww w .ja va 2 s . c o m*/ return new EdgeDriver(getInitializedEdgeOptions()); } catch (IllegalStateException e) { throwCustomExceptionIfExecutableWasNotFound(e); throw e; } }
From source file:org.musetest.selenium.providers.EdgeDriverProvider.java
License:Open Source License
@Override public WebDriver getDriver(SeleniumBrowserCapabilities capabilities, MuseExecutionContext context) { if (getOs() != null && !(OperatingSystem.get().equals(getOs()))) return null; // this provider is not for the current OS if (!capabilities.getName().equals(BrowserType.EDGE)) return null; File path = getDriverLocation(context); if (path == null) { context.raiseEvent(MessageEventType.create( "EdgeDriverProvider would try to satisfy request for Firefox browser, but it was not configured with a path to the driver")); return null; }//from ww w . j a va 2s.c om if (!(path.exists())) { context.raiseEvent(MessageEventType.create( "EdgeDriverProvider would try to satisfy request for Internet Explorer browser, but the configured path does not exist: " + path.getAbsolutePath())); return null; } synchronized (EdgeDriverProvider.class) { DesiredCapabilities desired = DesiredCapabilities.edge(); if (capabilities.getVersion() != null && capabilities.getVersion().length() > 0) desired.setVersion(capabilities.getVersion()); if (capabilities.getPlatform() != null && capabilities.getPlatform().length() > 0) desired.setPlatform(Platform.fromString(capabilities.getPlatform())); EdgeOptions options = new EdgeOptions(); options.merge(desired); if (getArguments() != null) LOG.error("Unable to set arguments for EdgeDriver: arguments are not supported by EdgeDriver"); System.setProperty("webdriver.edge.driver", path.getAbsolutePath()); return new EdgeDriver(options); } }
From source file:org.safs.selenium.webdriver.lib.SelectBrowser.java
License:Open Source License
/** * // w w w . j ava 2 s .c o m * @param browserName String, the browser name, such as "explorer". If null, then the * System.property {@link #SYSTEM_PROPERTY_BROWSER_NAME} is sought. If not set, then the * default {@link #BROWSER_NAME_FIREFOX} is used. * * @param extraParameters HashMap<String,Object>, can be used to pass more browser parameters, such as proxy settings. * @return WebDriver */ public static WebDriver getBrowserInstance(String browserName, HashMap<String, Object> extraParameters) { WebDriver instance = null; DesiredCapabilities caps = null; if (browserName == null || browserName.length() == 0) { browserName = System.getProperty(SYSTEM_PROPERTY_BROWSER_NAME); if (browserName == null || browserName.length() == 0) { browserName = BROWSER_NAME_FIREFOX; System.setProperty(SYSTEM_PROPERTY_BROWSER_NAME, browserName); } } String browserNameLC = browserName.toLowerCase(); //Prepare the Capabilities if (extraParameters == null || extraParameters.isEmpty()) { //Get proxy settings from System properties String proxy = System.getProperty(SelectBrowser.SYSTEM_PROPERTY_PROXY_HOST); String port = System.getProperty(SelectBrowser.SYSTEM_PROPERTY_PROXY_PORT); if (proxy != null && !proxy.isEmpty()) { String proxysetting = proxy; if (port != null && !port.isEmpty()) proxysetting += ":" + port; extraParameters.put(KEY_PROXY_SETTING, proxysetting); String bypass = System.getProperty(SelectBrowser.SYSTEM_PROPERTY_PROXY_BYPASS); if (proxy != null && !proxy.isEmpty()) { extraParameters.put(KEY_PROXY_BYPASS_ADDRESS, bypass); } } } if (extraParameters != null && !extraParameters.isEmpty()) { caps = getDesiredCapabilities(browserNameLC, extraParameters); } String installdir = System.getenv("SELENIUM_PLUS"); //Create the Driver if (browserNameLC.contains(BROWSER_NAME_IE)) { System.setProperty(SYSTEM_PROPERTY_WEBDRIVER_IE, installdir + "/extra/IEDriverServer.exe"); instance = (caps != null) ? new InternetExplorerDriver(caps) : new InternetExplorerDriver(); } else if (browserNameLC.equals(BROWSER_NAME_CHROME)) { System.setProperty(SYSTEM_PROPERTY_WEBDRIVER_CHROME, installdir + "/extra/chromedriver.exe"); instance = (caps != null) ? new ChromeDriver(caps) : new ChromeDriver(); } else if (browserNameLC.equals(BROWSER_NAME_EDGE)) { System.setProperty(SYSTEM_PROPERTY_WEBDRIVER_EDGE, installdir + "/extra/MicrosoftWebDriver.exe"); instance = (caps != null) ? new EdgeDriver(caps) : new EdgeDriver(); } else if (browserNameLC.equals(BROWSER_NAME_ANDROID_CHROME)) { System.setProperty(SYSTEM_PROPERTY_WEBDRIVER_CHROME, installdir + "/extra/chromedriver.exe"); instance = (caps != null) ? new ChromeDriver(caps) : new ChromeDriver(); } else { // default browser always instance = (caps != null) ? new FirefoxDriver(caps) : new FirefoxDriver(); } return instance; }