List of usage examples for org.openqa.selenium.remote RemoteWebDriver getCapabilities
@Override
public Capabilities getCapabilities()
From source file:org.eclipse.che.selenium.core.SeleniumWebDriver.java
License:Open Source License
private RemoteWebDriver doCreateDriver(URL webDriverUrl) { DesiredCapabilities capability;//w w w . ja va2s. c o m switch (browser) { case GOOGLE_CHROME: LoggingPreferences loggingPreferences = new LoggingPreferences(); loggingPreferences.enable(LogType.PERFORMANCE, Level.ALL); loggingPreferences.enable(LogType.BROWSER, Level.ALL); ChromeOptions options = new ChromeOptions(); options.addArguments("--no-sandbox"); options.addArguments("--dns-prefetch-disable"); options.addArguments("--ignore-certificate-errors"); // set parameters required for automatic download capability Map<String, Object> chromePrefs = new HashMap<>(); chromePrefs.put("download.default_directory", downloadDir); chromePrefs.put("download.prompt_for_download", false); chromePrefs.put("download.directory_upgrade", true); chromePrefs.put("safebrowsing.enabled", true); chromePrefs.put("profile.default_content_settings.popups", 0); chromePrefs.put("plugins.plugins_disabled", "['Chrome PDF Viewer']"); options.setExperimentalOption("prefs", chromePrefs); capability = DesiredCapabilities.chrome(); capability.setCapability(ChromeOptions.CAPABILITY, options); capability.setCapability(CapabilityType.LOGGING_PREFS, loggingPreferences); capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); break; default: capability = DesiredCapabilities.firefox(); capability.setCapability("dom.max_script_run_time", 240); capability.setCapability("dom.max_chrome_script_run_time", 240); } RemoteWebDriver driver = new RemoteWebDriver(webDriverUrl, capability); if (driver.getErrorHandler().isIncludeServerErrors() && driver.getCapabilities().getCapability("message") != null) { String errorMessage = format("Web driver creation error occurred: %s", driver.getCapabilities().getCapability("message")); LOG.error(errorMessage); throw new RuntimeException(errorMessage); } driver.manage().window().setSize(new Dimension(1920, 1080)); return driver; }
From source file:org.jboss.arquillian.ajocado2.reusable.TestCapabilitiesSerialization.java
License:Apache License
@Test public void whenGetCapabilitiesFromRunningSessionThenItShouldBeSerializable() { RemoteWebDriver driver = new RemoteWebDriver(HUB_URL, DesiredCapabilities.firefox()); Capabilities initializedCapabilities = driver.getCapabilities(); assertTrue("Capabilities obtained from running session should be serializable", initializedCapabilities instanceof Serializable); driver.quit();//from www . j a va2 s.c o m }
From source file:org.jboss.arquillian.ajocado2.reusable.TestReusingBrowserSession.java
License:Apache License
@Test public void whenBrowserSessionIsCreatedThenCouldBeReused() throws UnableReuseSessionException { RemoteWebDriver driver = new RemoteWebDriver(HUB_URL, DesiredCapabilities.firefox()); driver.navigate().to(SERVER_URL.toString()); Capabilities reusedCapabilities = serializeDeserialize(driver.getCapabilities()); SessionId reusedSessionId = new SessionId(serializeDeserialize(driver.getSessionId().toString())); ReusableRemoteWebDriver reusedDriver = new ReusableRemoteWebDriver(HUB_URL, reusedCapabilities, reusedSessionId);/*www .j a va 2 s . c o m*/ reusedDriver.navigate().to(HUB_URL.toString()); reusedDriver.quit(); }
From source file:org.jboss.arquillian.ajocado2.reusable.TestReusingBrowserSession.java
License:Apache License
@Test public void whenBrowserSessionIsCreatedAndQuitAndTriedToReuseThenItShouldThrowException() { RemoteWebDriver driver = new RemoteWebDriver(HUB_URL, DesiredCapabilities.firefox()); driver.navigate().to(SERVER_URL.toString()); Capabilities reusedCapabilities = serializeDeserialize(driver.getCapabilities()); SessionId reusedSessionId = new SessionId(serializeDeserialize(driver.getSessionId().toString())); driver.quit();/*from w ww .j a v a 2s. c o m*/ try { new ReusableRemoteWebDriver(HUB_URL, reusedCapabilities, reusedSessionId); fail("Original driver had quited before, so session should not be reusable"); } catch (UnableReuseSessionException e) { // exception should be thrown } }
From source file:org.jboss.arquillian.drone.webdriver.augmentation.AugmentingEnhancer.java
License:Apache License
/** * Unwraps the instance/*w w w . j a v a2 s. com*/ */ @Override public RemoteWebDriver deenhance(RemoteWebDriver enhancedInstance, Class<? extends Annotation> qualifier) { if (enhancedInstance instanceof DroneAugmented) { RemoteWebDriver original = (RemoteWebDriver) ((DroneAugmented) enhancedInstance).getWrapped(); Capabilities capabilities = enhancedInstance.getCapabilities(); if (capabilities != null) { ((DesiredCapabilities) enhancedInstance.getCapabilities()).setCapability(DRONE_AUGMENTED, Boolean.FALSE); } return original; } return enhancedInstance; }
From source file:org.jboss.arquillian.drone.webdriver.augmentation.TestAugmentingEnhancer.java
License:Apache License
@Test public void testEnhancing() { // given//w ww .j a v a 2s. co m DesiredCapabilities capabilities = new DesiredCapabilities(); RemoteWebDriver driver = mock(RemoteWebDriver.class); when(driver.getCapabilities()).thenReturn(capabilities); capabilities.setCapability(AugmentingEnhancer.DRONE_AUGMENTED, driver); capabilities.setCapability(CapabilityType.TAKES_SCREENSHOT, Boolean.TRUE); // when RemoteWebDriver enhanced = enhancer.enhance(driver, Default.class); // then assertThat(enhanced, instanceOf(DroneAugmented.class)); assertThat(enhanced, instanceOf(TakesScreenshot.class)); assertEquals(driver, ((DroneAugmented) enhanced).getWrapped()); }
From source file:org.jboss.arquillian.drone.webdriver.augmentation.TestAugmentingEnhancer.java
License:Apache License
@Test public void testDeenhancing() { // given/*from w w w.j av a 2 s .c o m*/ DesiredCapabilities capabilities = new DesiredCapabilities(); RemoteWebDriver driver = mock(RemoteWebDriver.class); when(driver.getCapabilities()).thenReturn(capabilities); capabilities.setCapability(AugmentingEnhancer.DRONE_AUGMENTED, driver); // when RemoteWebDriver enhanced = enhancer.enhance(driver, Default.class); assertThat(enhanced, instanceOf(DroneAugmented.class)); RemoteWebDriver deenhanced = enhancer.deenhance(enhanced, Default.class); // then assertEquals(driver, deenhanced); }
From source file:org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ftest.TestReusableRemoteWebDriver.java
License:Apache License
@Test public void whenBrowserIsCreatedThenCouldBeReused(@Drone @Reusable RemoteWebDriver driver) throws UnableReuseSessionException { driver.navigate().to(SERVER_URL.toString()); Capabilities reusedCapabilities = serializeDeserialize(driver.getCapabilities()); SessionId reusedSessionId = new SessionId(serializeDeserialize(driver.getSessionId().toString())); ReusableRemoteWebDriver reusedDriver = ReusableRemoteWebDriver.fromReusedSession(HUB_URL, reusedCapabilities, reusedSessionId); reusedDriver.navigate().to(HUB_URL.toString()); }
From source file:org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ftest.TestReusableRemoteWebDriver.java
License:Apache License
@Test public void whenBrowserIsCreatedAndQuitAndTriedToReuseThenItShouldThrowException( @Drone @Reusable RemoteWebDriver driver) { driver.navigate().to(SERVER_URL.toString()); Capabilities reusedCapabilities = serializeDeserialize(driver.getCapabilities()); SessionId reusedSessionId = new SessionId(serializeDeserialize(driver.getSessionId().toString())); driver.quit();//w w w . j av a 2 s. c om try { ReusableRemoteWebDriver.fromReusedSession(HUB_URL, reusedCapabilities, reusedSessionId); fail("Original driver had quited before, so session should not be reusable"); } catch (UnableReuseSessionException e) { // exception should be thrown } }
From source file:org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ReusableRemoteWebDriver.java
License:Apache License
private ReusableRemoteWebDriver(RemoteWebDriver remoteWebDriver) { super();/* w w w . j av a2 s . co m*/ setCommandExecutor(remoteWebDriver.getCommandExecutor()); reuseSession(remoteWebDriver.getSessionId(), remoteWebDriver.getCapabilities()); try { checkReusability(); } catch (UnableReuseSessionException e) { throw new IllegalStateException("Reusing RemoteWebDriver session unexpectedly failed", e); } }