List of usage examples for org.openqa.selenium WebDriver getCurrentUrl
String getCurrentUrl();
From source file:org.ocpsoft.rewrite.faces.jsession.JSessionIdTest.java
License:Apache License
@Test public void withCookiesAndStandardOutcome() throws Exception { // GIVEN a browser with cookies enabled WebDriver driver = createBrowserAndLoadPage(true); assertThat(driver.getPageSource(), Matchers.not(Matchers.containsString("jsessionid"))); // WHEN a JSF action redirects with a standard outcome driver.findElement(By.id("form:standardOutcome")).click(); // THEN the browser should be redirected assertThat(driver.getCurrentUrl(), Matchers.containsString("redirected=true")); // AND there should be no jsessionid in the URL assertThat(driver.getCurrentUrl(), Matchers.not(Matchers.containsString("jsessionid"))); }
From source file:org.ocpsoft.rewrite.faces.jsession.JSessionIdTest.java
License:Apache License
@Test public void withCookiesAndNavigateOutcome() throws Exception { // GIVEN a browser with cookies enabled WebDriver driver = createBrowserAndLoadPage(true); assertThat(driver.getPageSource(), Matchers.not(Matchers.containsString("jsessionid"))); // WHEN a JSF action redirects with a standard outcome driver.findElement(By.id("form:navigateOutcome")).click(); // THEN the browser should be redirected assertThat(driver.getCurrentUrl(), Matchers.containsString("redirected=true")); // AND there should be no jsessionid in the URL assertThat(driver.getCurrentUrl(), Matchers.not(Matchers.containsString("jsessionid"))); }
From source file:org.ocpsoft.rewrite.faces.jsession.JSessionIdTest.java
License:Apache License
@Test public void withoutCookiesAndStandardOutcome() throws Exception { // GIVEN a browser with cookies disabled WebDriver driver = createBrowserAndLoadPage(false); assertThat(driver.getPageSource(), Matchers.containsString("jsessionid")); // WHEN a JSF action redirects with a standard outcome driver.findElement(By.id("form:standardOutcome")).click(); // THEN the browser should be redirected assertThat(driver.getCurrentUrl(), Matchers.containsString("redirected=true")); // AND there should be a jsessionid in the URL assertThat(driver.getCurrentUrl(), Matchers.containsString("jsessionid")); }
From source file:org.ocpsoft.rewrite.faces.jsession.JSessionIdTest.java
License:Apache License
@Test public void withoutCookiesAndNavigateOutcome() throws Exception { // GIVEN a browser with cookies disabled WebDriver driver = createBrowserAndLoadPage(false); assertThat(driver.getPageSource(), Matchers.containsString("jsessionid")); // WHEN a JSF action redirects with a standard outcome driver.findElement(By.id("form:navigateOutcome")).click(); // THEN the browser should be redirected assertThat(driver.getCurrentUrl(), Matchers.containsString("redirected=true")); // AND there should be a jsessionid in the URL assertThat(driver.getCurrentUrl(), Matchers.containsString("jsessionid")); }
From source file:org.ocpsoft.rewrite.servlet.config.PathAndQueryTest.java
License:Apache License
@Test public void testWithQuery() throws Exception { WebDriver driver = new HtmlUnitDriver(); driver.get(baseUrl.toString() + "pathAndQuery/pathWithQuery?p1=foo&p2=bar"); assertThat(driver.getCurrentUrl()).endsWith("/resultingPath/pathWithQuery%3Fp1=foo&p2=bar"); }
From source file:org.ocpsoft.rewrite.servlet.config.PathAndQueryTest.java
License:Apache License
@Test public void testWithoutQuery() throws Exception { WebDriver driver = new HtmlUnitDriver(); driver.get(baseUrl.toString() + "pathAndQuery/pathWithoutQuery"); assertThat(driver.getCurrentUrl()).endsWith("/resultingPath/pathWithoutQuery"); }
From source file:org.ocpsoft.rewrite.servlet.config.RedirectWithAnchorTest.java
License:Apache License
@Test public void testRedirectToUrlWithAnchor() throws Exception { WebDriver driver = new HtmlUnitDriver(); driver.get(baseUrl.toString() + "do"); assertThat(driver.getCurrentUrl()).endsWith("/it#now"); }
From source file:org.opencastproject.loadtest.engage.LoadTestEngage.java
License:Educational Community License
/** * Start playing a new episode. //from w w w .j a v a 2 s . c o m */ public void playNewStream() { if (episodeList == null || episodeList.size() <= 0) { return; } String episodeUrl = engageServerUrl + "/engage/ui/watch.html?id=" + episodeList.get(generator.nextInt(episodeList.size())); driver.get(episodeUrl); if (!driver.getCurrentUrl().equalsIgnoreCase(episodeUrl)) { authenticate(); } logger.info(name + " - Playing episode " + episodeUrl); logger.debug("Episode Page title is: " + driver.getTitle()); // Play the episode. WebElement play = (new WebDriverWait(driver, 60)).until(new ExpectedCondition<WebElement>() { @Override public WebElement apply(WebDriver driver) { WebElement webElement = driver.findElement(By.id("oc_btn-play-pause")); if (webElement != null && webElement.isDisplayed()) { return webElement; } return null; } }); play.click(); // Advance the play using fast forward. WebElement fastForward = (new WebDriverWait(driver, 10000)).until(new ExpectedCondition<WebElement>() { @Override public WebElement apply(WebDriver driver) { WebElement webElement = driver.findElement(By.id("oc_btn-fast-forward")); if (webElement != null && webElement.isDisplayed()) { return webElement; } return null; } }); for (int i = 0; i < 5; i++) { fastForward.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { logger.error("There was an exception while fastforwarding:", e); } } }
From source file:org.openqa.grid.e2e.misc.Issue1586.java
License:Apache License
@Test(enabled = false) public void test() throws MalformedURLException { DesiredCapabilities ff = DesiredCapabilities.firefox(); WebDriver driver = null; try {// w ww . j a v a2s . com driver = new RemoteWebDriver(new URL(hub.getUrl() + "/grid/driver"), ff); for (int i = 0; i < 20; i++) { driver.get("http://code.google.com/p/selenium/"); WebElement keywordInput = driver.findElement(By.name("q")); keywordInput.clear(); keywordInput.sendKeys("test"); WebElement submitButton = driver.findElement(By.name("projectsearch")); submitButton.click(); driver.getCurrentUrl(); // fails here } } finally { if (driver != null) { driver.quit(); } } }
From source file:org.orcid.api.t2.integration.T2OrcidOAuthApiAuthorizationCodeIntegrationTest.java
License:Open Source License
private String obtainAuthorizationCode(String orcid, String scopes, String redirectUri) throws InterruptedException { webDriver.get(String.format("%s/oauth/authorize?client_id=%s&response_type=code&scope=%s&redirect_uri=%s", webBaseUrl, orcid, scopes, redirectUri)); WebElement userId = webDriver.findElement(By.id("userId")); userId.sendKeys("michael@bentine.com"); WebElement password = webDriver.findElement(By.id("password")); password.sendKeys("password"); password.submit();//from w ww . j a va 2 s . c o m (new WebDriverWait(webDriver, DEFAULT_TIMEOUT_SECONDS)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { if (d.getCurrentUrl().contains("authorize")) { WebElement authorizeButton = d.findElement(By.name("authorize")); if (authorizeButton != null) { return true; } } return false; } }); WebElement authorizeButton = webDriver.findElement(By.name("authorize")); Thread.sleep(3000); authorizeButton.submit(); (new WebDriverWait(webDriver, DEFAULT_TIMEOUT_SECONDS)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.getTitle().equals("ORCID Playground"); } }); String currentUrl = webDriver.getCurrentUrl(); Matcher matcher = AUTHORIZATION_CODE_PATTERN.matcher(currentUrl); assertTrue(matcher.find()); String authorizationCode = matcher.group(1); assertNotNull(authorizationCode); return authorizationCode; }