List of usage examples for org.openqa.selenium WebDriver get
void get(String url);
From source file:org.jboss.arquillian.graphene.context.TestGrapheneProxyHandler.java
License:Open Source License
@Test public void test_webDriver_methods_which_should_not_return_proxy() { IsNotProxyable isNotProxyable = new IsNotProxyable(); // when// w w w. j a v a 2 s.c o m WebDriver driver = Mockito.mock(WebDriver.class, isNotProxyable); Options options = mock(Options.class, isNotProxyable); Navigation navigation = mock(Navigation.class, isNotProxyable); ImeHandler ime = mock(ImeHandler.class, isNotProxyable); Logs logs = mock(Logs.class, isNotProxyable); // then try { driver.toString(); driver.close(); driver.equals(new Object()); driver.get(""); driver.getClass(); driver.getCurrentUrl(); driver.getPageSource(); driver.getTitle(); driver.getWindowHandle(); driver.hashCode(); driver.quit(); driver.toString(); options.addCookie(mock(Cookie.class)); options.deleteAllCookies(); options.deleteCookie(mock(Cookie.class)); options.deleteCookieNamed(""); options.getCookieNamed(""); navigation.back(); navigation.forward(); navigation.to(""); navigation.to(new URL("http://localhost/")); ime.activateEngine(""); ime.deactivate(); ime.getActiveEngine(); ime.isActivated(); logs.get(""); } catch (Exception e) { throw new RuntimeException(e); } assertEquals(Arrays.asList(), isNotProxyable.getViolations()); }
From source file:org.jboss.arquillian.graphene.ftest.Resource.java
License:Open Source License
public void loadPage(WebDriver browser, URL context) { browser.get(context.toString() + location); }
From source file:org.jboss.arquillian.graphene.location.LocationEnricher.java
License:Open Source License
private void handleLocationOf(Class<?> pageObjectClass, WebDriver browser) { Location location = pageObjectClass.getAnnotation(Location.class); if (location == null) { throw new IllegalArgumentException(String.format( "The page object '%s' that you are navigating to using either Graphene.goTo(<page_object>) or @InitialPage isn't annotated with @Location", pageObjectClass.getSimpleName())); }/*from w ww . ja v a2s . com*/ try { URL url = getURLFromLocation(location); browser.get(url.toExternalForm()); } catch (MalformedURLException e) { throw new IllegalArgumentException(String.format("Location '%s' specified on %s is not valid URL", location.value(), pageObjectClass.getSimpleName())); } }
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./*ww w. j av a 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.ConferenceFixture.java
License:Apache License
/** * Opens URL using new WebDriver.//from w w w .j ava 2 s . c om * @param URL the URL to be opened * @return the {@code WebDriver} which was started. * NOTE: Uses the browser type set for the owner. */ public static WebDriver openURL(String URL) { System.err.println("Opening URL: " + URL); BrowserType browser = BrowserType.valueOfString(System.getProperty(BROWSER_OWNER_NAME_PROP)); WebDriver driver = startDriver(browser, Participant.otherDriver); driver.get(URL); MeetUtils.waitForPageToLoad(driver); ((JavascriptExecutor) driver).executeScript("document.title='Other'"); return driver; }
From source file:org.jitsi.meet.test.ConferenceFixture.java
License:Apache License
/** * Hangs up the Jitsi-Meet call running in {@code participant} without * closing the driver. If we fail hanging up we close and the driver. * @param participant the participant./* www. j a va 2s. c o m*/ */ public static void close(WebDriver participant) { if (participant == null) { System.err.println("close(): participant is null"); return; } MeetUIUtils.clickOnToolbarButton(participant, "toolbar_button_hangup", false); TestUtils.waitMillis(500); if (participant == owner) { ownerHungUp = true; } else if (participant == secondParticipant) { secondParticipantHungUp = true; } else if (participant == thirdParticipant) { thirdParticipantHungUp = true; } String instanceName = getParticipantName(participant); System.err.println("Hung up in " + instanceName + "."); // open a blank page after hanging up, to make sure // we will successfully navigate to the new link containing the // parameters, which change during testing participant.get("about:blank"); MeetUtils.waitForPageToLoad(participant); }
From source file:org.julianharty.accessibility.automation.eBayHomepage.java
License:Apache License
public void testTabbingThroughEbayHomepage() throws InterruptedException { WebDriver driver = new FirefoxDriver(); driver.get("http://www.ebay.co.uk"); int maxTabsToEnter = 300; int tabs = KeyboardHelpers.tabThroughWebPage(driver, maxTabsToEnter); assertTrue("Expected at least 50 tabs, only needed " + tabs, tabs > 50); }
From source file:org.julianharty.accessibility.automation.Example.java
License:Apache License
/** * Simple program to allow quick assessments of web pages. * @param args Command Line parameters.//from w ww. j av a 2s . c o m */ public static void main(String[] args) { if (args.length >= 2) { maxTabsToEnter = Integer.parseInt(args[1]); } else { maxTabsToEnter = 50; } if (args.length >= 1) { urlToVisit = args[0]; } else { urlToVisit = "http://www.google.com"; } WebDriver driver = new ChromeDriver(); driver.get(urlToVisit); File screenshotFileBeforeTest = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); System.out.println(screenshotFileBeforeTest.getPath()); try { int tabs = KeyboardHelpers.tabThroughWebPage(driver, maxTabsToEnter); System.out.println(tabs + " were issued."); } catch (InterruptedException e) { e.printStackTrace(); } catch (WebDriverException wde) { wde.printStackTrace(); } File screenshotFileAfterTest = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); System.out.println(screenshotFileAfterTest.getPath()); }
From source file:org.julianharty.accessibility.automation.GoogleSearchResults.java
License:Apache License
public void testTabbingThroughGoogleSearchResults() throws InterruptedException { WebDriver driver = new ChromeDriver(); driver.get("http://www.google.co.uk/search?q=cheese"); int maxTabsToEnter = MAXIMUM_TAB_COUNT; int tabs = KeyboardHelpers.tabThroughWebPage(driver, maxTabsToEnter); assertTrue(String.format("Expected at least %02d tabs, only needed " + tabs, MINIMUM_TAB_COUNT), tabs > MINIMUM_TAB_COUNT); }
From source file:org.kuali.rice.testtools.selenium.WebDriverUtils.java
License:Educational Community License
public static void openTestUrl(WebDriver driver, String testUrl) { driver.manage().timeouts().implicitlyWait(WebDriverUtils.SETUP_URL_LOAD_WAIT_SECONDS, TimeUnit.SECONDS); driver.get(testUrl); if (!System.getProperty(SauceLabsWebDriverHelper.SAUCE_BROWSER_PROPERTY, "ff").equals("opera")) { driver.manage().window().maximize(); // driver.manage().window().setSize(new Dimension(800,600)); }/*w w w.java 2s .c om*/ WebDriverUtils.jGrowl(driver, "Open URL", false, "Open " + testUrl); driver.manage().timeouts().implicitlyWait(WebDriverUtils.configuredImplicityWait(), TimeUnit.SECONDS); }