List of usage examples for org.openqa.selenium WebDriver getCurrentUrl
String getCurrentUrl();
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.pages.EnvironmentDetailsPageSeleniumImpl.java
License:Apache License
private void assertWeAreInTheRequiredPage(WebDriver wd) { try {/*from w ww .ja va2s . c o m*/ wd.findElement(By.xpath("//title[contains(.,'orange paas - environment details')]")); } catch (NoSuchElementException e) { logger.error( "you are not in environment details page because current page title does not contain [orange paas - environment details]"); logger.error("current page title is : " + wd.getTitle()); logger.error("current url is : " + wd.getCurrentUrl()); logger.error("current page source is: " + wd.getPageSource()); throw new IllegalStateException("this is not the environment detail page"); } logger.debug("current url is : " + wd.getCurrentUrl()); logger.debug("current page title is : " + wd.getTitle()); }
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.pages.EnvironmentsOverviewPage.java
License:Apache License
public EnvironmentsOverviewPage(WebDriver wd) { super(wd);//ww w.j a v a2 s . c o m logger.debug("current url is : " + wd.getCurrentUrl()); logger.debug("page title : " + wd.getTitle()); // check that we are on the right page if (!"orange paas - environments overview".equals(wd.getTitle())) { throw new IllegalStateException("this is not the environment overview page: " + wd.getTitle()); } logger.debug("you are in environments overview page"); }
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.pages.HomePage.java
License:Apache License
public HomePage(WebDriver wd) { super(wd);/*from w w w . jav a2 s . c o m*/ logger.debug("current url is : " + wd.getCurrentUrl()); logger.debug("page title : " + wd.getTitle()); // assert that we are on the right page if (!"orange paas - home page".equals(wd.getTitle())) { throw new IllegalStateException("this is not the home page, title page = " + wd.getTitle()); } logger.debug("you are in home page"); }
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.pages.LoginPage.java
License:Apache License
public LoginPage(WebDriver wd) { super(wd);//from ww w.jav a2s . c o m logger.debug("current url is : " + wd.getCurrentUrl()); logger.debug("page title : " + wd.getTitle()); // assert that we are on the right page if (!"Orange PaaS login".equals(wd.getTitle())) { throw new IllegalStateException("this is not the login page, title page = " + wd.getTitle()); } logger.debug("you are in login page"); }
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.pages.PopulatePage.java
License:Apache License
public PopulatePage(WebDriver wd) { super(wd);// w w w . j av a 2 s.c o m logger.debug("current url is : " + wd.getCurrentUrl()); logger.debug("page title : " + wd.getTitle()); // assert that we are on the right page if (!"orange paas - populate data".equals(wd.getTitle())) { throw new IllegalStateException("this is not the populate data page, title page = " + wd.getTitle()); } logger.debug("you are in populate data page"); }
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.pages.ReleasesOverviewPage.java
License:Apache License
public ReleasesOverviewPage(WebDriver wd) { super(wd);/* w w w .j av a 2s .c o m*/ logger.debug("current url is : " + wd.getCurrentUrl()); logger.debug("page title : " + wd.getTitle()); // assert that we are on the right page if (!"orange paas - releases overview".equals(wd.getTitle())) { throw new IllegalStateException( "this is not the releases overview page, title page = " + wd.getTitle()); } logger.debug("you are in release overview page"); }
From source file:com.gargoylesoftware.htmlunit.HistoryTest.java
License:Apache License
/** * Tests going in history {@link History#back()} with {@code POST} request. * * @throws Exception if an error occurs/*from w ww . j av a 2 s. c om*/ */ @Test public void post() throws Exception { final Map<String, Class<? extends Servlet>> servlets = new HashMap<>(); servlets.put("/post1", Post1Servlet.class); servlets.put("/post2", Post2Servlet.class); servlets.put("/post3", Post3Servlet.class); startWebServer("./", new String[0], servlets); final WebDriver driver = getWebDriver(); driver.get(URL_FIRST + "post1"); driver.findElement(By.id("mySubmit")).click(); assertEquals(URL_FIRST + "post2", driver.getCurrentUrl()); assertTrue(driver.getPageSource().contains("POST")); assertTrue(driver.getPageSource().contains("para1=value1")); driver.findElement(By.linkText("Go to GET")).click(); assertEquals(URL_FIRST + "post3", driver.getCurrentUrl()); assertTrue(driver.getPageSource().contains("GET")); driver.navigate().back(); assertEquals(URL_FIRST + "post2", driver.getCurrentUrl()); assertTrue(driver.getPageSource().contains("POST")); assertTrue(driver.getPageSource().contains("para1=value1")); }
From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchor2Test.java
License:Apache License
/** * @throws Exception if an error occurs/*w w w.ja v a 2 s .c om*/ */ @Test public void clickNestedElement() throws Exception { final String html = "<html>\n" + "<body>\n" + " <a href='page2.html'>\n" + " <span id='theSpan'>My Link</span>\n" + " </a>\n" + "</body></html>"; getMockWebConnection().setDefaultResponse(""); final WebDriver driver = loadPage2(html); final WebElement span = driver.findElement(By.id("theSpan")); assertEquals("span", span.getTagName()); span.click(); assertEquals(new URL(getDefaultUrl(), "page2.html").toString(), driver.getCurrentUrl()); }
From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchor2Test.java
License:Apache License
/** * @throws Exception if an error occurs//from w w w .j av a2 s .c o m */ @Test public void clickNestedButtonElement() throws Exception { final String html = "<html>\n" + "<body>\n" + " <a href='page2.html'>\n" + " <button id='theButton'></button>\n" + " </a>\n" + "</body></html>"; getMockWebConnection().setDefaultResponse(""); final WebDriver driver = loadPage2(html); final WebElement button = driver.findElement(By.id("theButton")); assertEquals("button", button.getTagName()); button.click(); assertEquals(new URL(getDefaultUrl(), "page2.html").toString(), driver.getCurrentUrl()); }
From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchor2Test.java
License:Apache License
/** * @throws Exception if an error occurs// ww w . j a v a2s.co m */ @Test @Alerts(DEFAULT = "page2.html", CHROME = "", IE = "") public void clickNestedCheckboxElement() throws Exception { final String html = "<html>\n" + "<body>\n" + " <a href='page2.html'>\n" + " <input type='checkbox' id='theCheckbox' name='myCheckbox' value='Milk'>\n" + " </a>\n" + "</body></html>"; getMockWebConnection().setDefaultResponse(""); final WebDriver driver = loadPage2(html); final WebElement checkbox = driver.findElement(By.id("theCheckbox")); assertEquals("input", checkbox.getTagName()); checkbox.click(); assertEquals(new URL(getDefaultUrl(), getExpectedAlerts()[0]).toString(), driver.getCurrentUrl()); }