@Test public void shouldCreateLocalDriverInstance() { Browser edge = StreamEx.of(browsers) .findFirst(f -> f.name() == Browser.Name.Edge) .orElseThrow(() -> new AssertionError( "Unable to get Edge implementation")); XmlConfig config = new XmlConfig(new HashMap<String, String>() { { put(BROWSER_NAME, "edge"); } }); PowerMockito.mockStatic(WebDriverManager.class); BrowserManager browserManager = mock(BrowserManager.class, RETURNS_DEEP_STUBS); WebDriver driver = mock(EdgeDriver.class, RETURNS_DEEP_STUBS); WebDriverProvider spyFactory = spy(defaultFactory); Reflect spyReflectedDriver = spy(spyFactory.wrapDriver(edge)); PowerMockito.when(WebDriverManager.getInstance(spyReflectedDriver.type())).thenReturn(browserManager); doNothing().when(browserManager).setup(); doReturn(spyReflectedDriver).when(spyFactory).wrapDriver(edge); doReturn(on(driver)).when(spyReflectedDriver).create(edge.configuration(config)); assertThat(spyFactory.createDriver(edge, config)).isInstanceOf(EdgeDriver.class); }
public SeleniumExtension() { handlerMap.put(ChromeDriver.class, ChromeDriverHandler.class); handlerMap.put(FirefoxDriver.class, FirefoxDriverHandler.class); handlerMap.put(EdgeDriver.class, EdgeDriverHandler.class); handlerMap.put(OperaDriver.class, OperaDriverHandler.class); handlerMap.put(SafariDriver.class, SafariDriverHandler.class); handlerMap.put(RemoteWebDriver.class, RemoteDriverHandler.class); handlerMap.put(AppiumDriver.class, AppiumDriverHandler.class); handlerMap.put(List.class, ListDriverHandler.class); handlerMap.put(PhantomJSDriver.class, OtherDriverHandler.class); templateHandlerMap.put("chrome", ChromeDriver.class); templateHandlerMap.put("firefox", FirefoxDriver.class); templateHandlerMap.put("edge", EdgeDriver.class); templateHandlerMap.put("opera", OperaDriver.class); templateHandlerMap.put("safari", SafariDriver.class); templateHandlerMap.put("appium", AppiumDriver.class); templateHandlerMap.put("phantomjs", PhantomJSDriver.class); templateHandlerMap.put("chrome-in-docker", RemoteWebDriver.class); templateHandlerMap.put("firefox-in-docker", RemoteWebDriver.class); templateHandlerMap.put("opera-in-docker", RemoteWebDriver.class); }
@Override public void resolve() { try { Optional<Object> testInstance = context.getTestInstance(); Optional<Capabilities> capabilities = annotationsReader .getCapabilities(parameter, testInstance); EdgeOptions edgeOptions = (EdgeOptions) getOptions(parameter, testInstance); if (capabilities.isPresent()) { edgeOptions.merge(capabilities.get()); } object = new EdgeDriver(edgeOptions); } catch (Exception e) { handleException(e); } }
WebDriver start(Capabilities capabilities) { switch (this) { case FIREFOX: return new FirefoxDriver(capabilities); case HTML_UNIT: return new HtmlUnitDriver(capabilities); case CHROME: return new ChromeDriver(capabilities); case EDGE: return new EdgeDriver(capabilities); case INTERNET_EXPLORER: return new InternetExplorerDriver(capabilities); case SAFARI: return new SafariDriver(capabilities); default: throw new AssertionError(); } }
boolean initED(String url, String path) { //Edge try { System.setProperty("webdriver.edge.driver", path); driver = new EdgeDriver(); js = (JavascriptExecutor) driver; writer.writeHeader(url, "ED"); driver.get(url); } catch (IllegalStateException ise) { ui.errorMessage("Path to Edge driver is invalid, check settings."); return false; } catch (InvalidArgumentException iae) { ui.errorMessage("Invalid URL?"); return false; } catch (Exception e) { System.err.println(e); return false; } return true; }
public static WebDriver getDriver(String browserType){ if ( StringUtils.isEmpty(browserType) || FIREFOX.equals(browserType)) { return new FirefoxDriver(SeleniumBrowserFactory.getBrowserCapabilities(browserType)); } else if (CHROME.equals(browserType)) { return new ChromeDriver(SeleniumBrowserFactory.getBrowserCapabilities(browserType)); } else if (IE.equals(browserType)) { return new InternetExplorerDriver(SeleniumBrowserFactory.getBrowserCapabilities(browserType)); } else if (PHANTOMJS.equals(browserType)) { return new PhantomJSDriver(); } else if (SAFARI.equals(browserType)) { return new SafariDriver(); } else if (EDGE.equals(browserType)) { return new EdgeDriver(); } else { throw new RuntimeException(String.format("Unknown browser type: \"%s\"", browserType)); } }
private WebDriver edge(DesiredCapabilities customDesiredCapabilities) { EdgeDriverManager.getInstance().setup(); DesiredCapabilities desiredCapabilities = getEdgeDesiredCapabilities(); if (!customDesiredCapabilities.asMap().isEmpty()) { desiredCapabilities.merge(customDesiredCapabilities); } return new EdgeDriver(desiredCapabilities); }
static Stream<Arguments> forcedTestProvider() { return Stream.of( Arguments.of(AppiumDriverHandler.class, ForcedAppiumJupiterTest.class, AppiumDriver.class, "appiumNoCapabilitiesTest"), Arguments.of(AppiumDriverHandler.class, ForcedAppiumJupiterTest.class, AppiumDriver.class, "appiumWithCapabilitiesTest"), Arguments.of(ChromeDriverHandler.class, ForcedBadChromeJupiterTest.class, ChromeDriver.class, "chromeTest"), Arguments.of(FirefoxDriverHandler.class, ForcedBadFirefoxJupiterTest.class, FirefoxDriver.class, "firefoxTest"), Arguments.of(RemoteDriverHandler.class, ForcedBadRemoteJupiterTest.class, RemoteWebDriver.class, "remoteTest"), Arguments.of(EdgeDriverHandler.class, ForcedEdgeJupiterTest.class, EdgeDriver.class, "edgeTest"), Arguments.of(OperaDriverHandler.class, ForcedOperaJupiterTest.class, OperaDriver.class, "operaTest"), Arguments.of(SafariDriverHandler.class, ForcedSafariJupiterTest.class, SafariDriver.class, "safariTest")); }
@ParameterizedTest @MethodSource("testClassProvider") void testEdgeOptions(Class<?> testClass) throws Exception { Parameter parameter = testClass.getMethod("edgeTest", EdgeDriver.class) .getParameters()[0]; Optional<Object> testInstance = Optional.of(testClass.newInstance()); EdgeOptions edgeOptions = (EdgeOptions) annotationsReader .getOptions(parameter, testInstance); assertThat(edgeOptions.getCapability("pageLoadStrategy"), equalTo("eager")); }
/** * {@inheritDoc} */ @Override public EdgeDriver start(Capabilities other) { Capabilities capabilities = this.mergeCapabilities(other); if (capabilities == null) { return new EdgeDriver(); } return new EdgeDriver(capabilities); }
/** * Load the default configuration. It will not erase previous non-default configurations. * * @return Itself. */ public SeleniumConfiguration loadDefaultConfiguration() { this.getConfiguration().put(ChromeDriver.class, new ChromeConfiguration()); this.getConfiguration().put(EdgeDriver.class, new EdgeConfiguration()); this.getConfiguration().put(FirefoxDriver.class, new FirefoxConfiguration()); this.getConfiguration().put(HtmlUnitConfiguration.class, new HtmlUnitConfiguration()); this.getConfiguration().put(InternetExplorerConfiguration.class, new InternetExplorerConfiguration()); this.getConfiguration().put(OperaConfiguration.class, new OperaConfiguration()); this.getConfiguration().put(PhantomJSConfiguration.class, new PhantomJSConfiguration()); this.getConfiguration().put(SafariDriver.class, new SafariConfiguration()); return this; }
@Override protected WebDriver getDriver() throws Exception { System.setProperty( "webdriver.edge.driver", "C:/Program Files (x86)/Microsoft Web Driver/MicrosoftWebDriver.exe" ); return new EdgeDriver(); }
public EdgeFactory() { super(new Function<DesiredCapabilities, WebDriver>() { @Override public WebDriver apply(DesiredCapabilities capabilities) { return new EdgeDriver(capabilities); } }); }
@Override public WebDriver createWebDriver(String sessionName) { return new EdgeDriver(createOptions()); }
@Override public WebDriver createDriver(Capabilities capabilities) { String driverVersion = (String) capabilities.getCapability(CAPABILITY_DRIVER_VERSION); EdgeDriverManager.getInstance().version(driverVersion).setup(); return new EdgeDriver((EdgeOptions) capabilities); }
@Test public void edgeTest(EdgeDriver driver) { assumeFalse(IS_OS_WINDOWS); assertThat(driver, nullValue()); }
@Test public void edgeTest(EdgeDriver driver) { driver.get("http://www.seleniumhq.org/"); assertThat(driver.getTitle(), containsString("A JUnit 5 extension for Selenium WebDriver")); }
@Test void webrtcTest(EdgeDriver driver) { driver.get("http://www.seleniumhq.org/"); assertThat(driver.getTitle(), containsString("A JUnit 5 extension for Selenium WebDriver")); }
@Test void edgeTest(EdgeDriver driver) { driver.get("https://bonigarcia.github.io/selenium-jupiter/"); assertThat(driver.getTitle(), containsString("A JUnit 5 extension for Selenium WebDriver")); }
public EdgeFactory() { super(EdgeDriver::new); }
@Before public void setupTest() { driver = new EdgeDriver(); }
@Before public void setup() { browserManager = WebDriverManager.getInstance(EdgeDriver.class); os = WIN; specificVersions = new String[] { "3.14393", "4.15063" }; }
@Override public WebDriver createDriver() throws Exception { final WebDriver driver = new EdgeDriver(); manage(driver); return driver; }
public Browser createBrowser() { EdgeDriverService service = EdgeDriverService.createDefaultService(); DesiredCapabilities capabilities = getDefaultCapabilities(); return createBrowser(new EdgeDriver(service, capabilities)); }
/** * Get the default {@link EdgeDriver} configuration. * * @return The default {@link EdgeDriver} configuration. */ public EdgeConfiguration edge() { return (EdgeConfiguration) this.getConfiguration().get(EdgeDriver.class); }
/** * Set the default {@link EdgeDriver} configuration. * * @param configuration * The {@link EdgeDriver} configuration. * * @return Itself. */ public SeleniumConfiguration edge(EdgeConfiguration configuration) { return this.setDriverConfiguration(EdgeDriver.class, configuration, new EdgeConfiguration()); }