List of usage examples for org.openqa.selenium WebDriver manage
Options manage();
From source file:org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ftest.TestReusingCookies.java
License:Apache License
@Test @InSequence(4)//from w w w . j a va2s . c o m public void testCookieWasNotThereAgain(@Drone @ReuseCookies WebDriver driver) { driver.get(HUB_URL.toString()); Assert.assertNull("Cookie is not there", driver.manage().getCookieNamed("foo")); }
From source file:org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ftest.TestReusingCookies.java
License:Apache License
@Test @InSequence(5)//from w ww . java 2 s. c om public void testCookieWasStoredAgain(@Drone @ReuseCookies WebDriver driver) { driver.get(HUB_URL.toString()); driver.manage().addCookie(new Cookie("foo", "bar")); Assert.assertNotNull("Cookie was stored", driver.manage().getCookieNamed("foo")); Assert.assertEquals("Cookie was stored", "bar", driver.manage().getCookieNamed("foo").getValue()); }
From source file:org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ftest.TestReusingCookies.java
License:Apache License
@Test @InSequence(6)/* w w w . j a v a 2 s . c o m*/ public void testCookieWasNotDeleted(@Drone @ReuseCookies WebDriver driver) { driver.get(HUB_URL.toString()); Assert.assertNotNull("Cookie was stored", driver.manage().getCookieNamed("foo")); Assert.assertEquals("Cookie was stored", "bar", driver.manage().getCookieNamed("foo").getValue()); }
From source file:org.jboss.arquillian.drone.webdriver.window.WindowResizer.java
License:Apache License
private void safelyResizeWindow(WebDriver driver, int width, int height, Class<?> droneType, Class<? extends Annotation> qualifier, Class<?> realInstanceClass) { try {//from w w w .j a v a 2s . c om driver.manage().window().setSize(new Dimension(width, height)); } catch (WebDriverException e) { log.log(Level.WARNING, "Ignoring request to resize browser window to {3}x{4} for {0} @{1}, not supported for {2}", new Object[] { droneType.getSimpleName(), qualifier.getSimpleName(), realInstanceClass.getName(), width, height }); } catch (UnsupportedOperationException e) { log.log(Level.WARNING, "Ignoring request to resize browser window to {3}x{4} for {0} @{1}, not supported for {2}", new Object[] { droneType.getSimpleName(), qualifier.getSimpleName(), realInstanceClass.getName(), width, height }); } }
From source file:org.jboss.arquillian.graphene.context.TestGrapheneProxyHandler.java
License:Open Source License
@Test public void test_webDriver_methods_which_should_return_proxy() { IsProxyable isProxyable = new IsProxyable(); // when//www . j a va2 s. c o m WebDriver driver = Mockito.mock(WebDriver.class, isProxyable); Options options = mock(Options.class, isProxyable); TargetLocator targetLocator = mock(TargetLocator.class, isProxyable); ImeHandler ime = mock(ImeHandler.class, isProxyable); Timeouts timeouts = mock(Timeouts.class, isProxyable); // then try { driver.manage(); driver.navigate(); driver.switchTo(); driver.findElement(By.className("")); driver.findElements(By.className("")); driver.getWindowHandles(); options.ime(); options.logs(); options.timeouts(); options.window(); options.getCookies(); targetLocator.activeElement(); targetLocator.alert(); targetLocator.defaultContent(); targetLocator.frame(0); targetLocator.frame("name"); targetLocator.frame(mock(WebElement.class)); targetLocator.window("name"); ime.getAvailableEngines(); timeouts.implicitlyWait(1L, TimeUnit.MICROSECONDS); timeouts.setScriptTimeout(1L, TimeUnit.MICROSECONDS); } catch (Exception e) { throw new RuntimeException(e); } assertEquals(Arrays.asList(), isProxyable.getViolations()); }
From source file:org.jboss.test.selenium.listener.BrowserConsoleLogSaverListener.java
License:Open Source License
/** * Save the browser console log to file ${maven.project.build.directory}/browserConsole.log *//*from w w w .j a v a2 s . co m*/ private void saveLog(ITestResult result) { WebDriver wd = getWebDriver(); if (wd == null) { System.err.println("Can't save the browser console logs, because there is no driver available."); return; } LogEntries logEntries = wd.manage().logs().get(LogType.BROWSER); String msg; try { FileUtils.forceMkdir(OUTPUT_FILE.getParentFile()); for (LogEntry entry : logEntries) { if (LOOK_FOR_MESSAGES_LEVEL.contains(entry.getLevel())) { msg = format("{0} method: {1}, level: {2}, message: {3}", DATE_FORMAT.format(new Date(entry.getTimestamp())), getPackageClassMethodName(result), entry.getLevel(), entry.getMessage()); for (String error : POSSIBLE_CONSOLE_ERRORS) { if (msg.toLowerCase().contains(error)) { errorsCount++; break; } } if (!msg.endsWith(NEW_LINE)) { msg = msg.concat(NEW_LINE); } FileUtils.writeStringToFile(OUTPUT_FILE, msg, APPEND); } } } catch (IOException ex) { System.err.println("Can't save the browser console logs: " + ex.getMessage()); } }
From source file:org.jitsi.meet.test.ConferenceFixture.java
License:Apache License
/** * Opens the room for the given participant. * * @param participant to open the current test room. * @param fragment adds the given string to the fragment part of the URL * @param browser the browser type./* w ww .java 2 s.c om*/ */ public static void openRoom(WebDriver participant, String fragment, BrowserType browser) { String URL = System.getProperty(JITSI_MEET_URL_PROP) + "/" + currentRoomName; URL += "#config.requireDisplayName=false"; URL += "&config.debug=true"; URL += "&config.disableAEC=true"; URL += "&config.disableNS=true"; URL += "&config.callStatsID=false"; URL += "&config.alwaysVisibleToolbar=true"; if (fragment != null) URL += "&" + fragment; if (browser == BrowserType.firefox) URL += "&config.firefox_fake_device=true"; String participantName = getParticipantName(participant); System.err.println(participantName + " is opening URL: " + URL); { // with chrome v52 we start getting error: // "Timed out receiving message from renderer" and // "Navigate timeout: cannot determine loading status" // seems its a bug or rare problem, maybe concerns async loading // of resources ... // https://bugs.chromium.org/p/chromedriver/issues/detail?id=402 // even there is a TimeoutException the page is loaded correctly // and driver is operating, we just lower the page load timeout // default is 3 minutes and we log and skip this exception participant.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); try { participant.get(URL); } catch (org.openqa.selenium.TimeoutException ex) { ex.printStackTrace(); System.err.println( "TimeoutException while loading page, " + "will skip it and continue:" + ex.getMessage()); } } MeetUtils.waitForPageToLoad(participant); // disables animations ((JavascriptExecutor) participant).executeScript("try { jQuery.fx.off = true; } catch(e) {}"); // disables mute participant dialog ((JavascriptExecutor) participant).executeScript("if(window.localStorage)" + "window.localStorage.setItem(" + "'dontShowMuteParticipantDialog', 'true');"); ((JavascriptExecutor) participant).executeScript("APP.UI.dockToolbar(true);"); // Hack-in disabling of callstats (old versions of jitsi-meet don't // handle URL parameters) ((JavascriptExecutor) participant).executeScript("config.callStatsID=false;"); String version = TestUtils.executeScriptAndReturnString(participant, "return JitsiMeetJS.version;"); System.err.println(participantName + " lib-jitsi-meet version: " + version); }
From source file:org.jitsi.meet.test.FailureListener.java
License:Apache License
/** * Saves browser console logs.// www . ja v a 2s.co m */ private void saveBrowserLogs(WebDriver driver, String fileNamePrefix, String suffix, String extension) { try { LogEntries logs = driver.manage().logs().get(LogType.BROWSER); BufferedWriter out = new BufferedWriter(new FileWriter( new File(outputLogsParentFolder, fileNamePrefix + suffix + "-driver" + extension))); Iterator<LogEntry> iter = logs.iterator(); while (iter.hasNext()) { LogEntry e = iter.next(); out.write(e.toString()); out.newLine(); out.newLine(); } out.flush(); out.close(); if (ConferenceFixture.getBrowserType(driver) == ConferenceFixture.BrowserType.chrome) { FileUtils.copyFile(new File(outputLogsParentFolder, "chrome" + suffix + ".log"), new File(outputLogsParentFolder, fileNamePrefix + suffix + "-chrome" + extension)); } } catch (IOException e) { // cannot create file or something } }
From source file:org.keycloak.testsuite.cluster.AuthenticationSessionFailoverClusterTest.java
License:Apache License
public static String getAuthSessionCookieValue(WebDriver driver) { Cookie authSessionCookie = driver.manage().getCookieNamed(AuthenticationSessionManager.AUTH_SESSION_ID); Assert.assertNotNull(authSessionCookie); return authSessionCookie.getValue(); }
From source file:org.keycloak.testsuite.drone.KeycloakDronePostSetup.java
License:Apache License
private void configureDriverSettings(WebDriver driver) { long implicitWaitMillis = WaitUtils.IMPLICIT_ELEMENT_WAIT_MILLIS; long pageLoadTimeoutMillis = WaitUtils.PAGELOAD_TIMEOUT_MILLIS; log.infof("Configuring driver settings. implicitWait=%d, pageLoadTimeout=%d", implicitWaitMillis, pageLoadTimeoutMillis);/* w ww . ja va 2s.co m*/ driver.manage().timeouts().implicitlyWait(implicitWaitMillis, TimeUnit.MILLISECONDS); driver.manage().timeouts().pageLoadTimeout(pageLoadTimeoutMillis, TimeUnit.MILLISECONDS); driver.manage().window().maximize(); }