List of usage examples for org.openqa.selenium.support.ui ExpectedConditions urlContains
public static ExpectedCondition<Boolean> urlContains(final String fraction)
From source file:com.ionidea.RegressionNGA.Tests.FooterTest.java
License:Open Source License
/** * the method verifies that the opened page is respective to the used sub menu option * @param url //from w ww. j a va 2 s. c o m * @param link */ public void verifyFooterLinks(String url, WebElement link) throws InterruptedException { driver.get(m_baseUrl); String mainHandle = driver.getWindowHandle(); //Click on the link m_wait.until(ExpectedConditions.elementToBeClickable(link)); link.click(); //create excplicite wait Thread.sleep(2000); if (url == "https://www.google.com/maps/place/Constitution+Ave+") { for (String winHandle : driver.getWindowHandles()) { driver.switchTo().window(winHandle); if (driver.getCurrentUrl().contains("https://www.google.com/maps/place/Constitution+Ave+")) { ; driver.close(); driver.switchTo().window(mainHandle); break; } } } else { //WebDriverWait wait = new WebDriverWait(driver,30000); m_wait.until(ExpectedConditions.urlContains(url)); //verify URL and title of the opened page Assert.assertTrue(driver.getCurrentUrl().contains(url)); } }
From source file:com.ionidea.RegressionNGA.Tests.MainPageHeaderTest.java
/** * the method verifies that the opened page is respective to the used sub menu option * @param relativeUrl /*w w w . java 2s . c o m*/ * @param mainMenu */ public void verifyOpenedPage(String relativeUrl, String title, Integer mainMenuIndex) { //verify that the title contains correct value if (mainMenuIndex == 8) { m_wait.until(ExpectedConditions.urlContains("https://shop.nga.gov" + relativeUrl)); Assert.assertTrue(driver.getCurrentUrl().contains("https://shop.nga.gov" + relativeUrl)); System.out.println(relativeUrl); } else { m_wait.until(ExpectedConditions.urlContains(m_baseUrl + relativeUrl)); Assert.assertTrue(driver.getCurrentUrl().contains(m_baseUrl + relativeUrl)); System.out.println(relativeUrl); } //verify that the URL of opened page is correct m_wait.until(ExpectedConditions.titleContains(title)); Assert.assertTrue(driver.getTitle().contains(title)); System.out.println("the page is loaded"); }
From source file:com.java.cukes.CheckoutSteps.java
License:Apache License
@Then("^I should see order confirmation message$") public void I_should_see_order_confirmation_message() throws Throwable { new WebDriverWait(driver, 60).until(ExpectedConditions.urlContains("success")); assertEquals(driver.findElement(By.tagName("h1")).getText(), "YOUR ORDER HAS BEEN RECEIVED."); assertEquals(driver.findElement(By.tagName("h2")).getText(), "THANK YOU FOR YOUR PURCHASE!"); }
From source file:com.synapticpath.naica.selenium.SeleniumUtils.java
License:Open Source License
/** * Polls through Selenium driver until:/*from w ww . j av a 2s .c om*/ * a) browser URL contains desired String * b) timeout is reached * * @param text * @param timeout * @return true when url contains the text, false if timeout reached. */ public static boolean waitUntilUrlContains(final String text, int timeout) { final WebDriver driver = SeleniumTestContext.getInstance().getDriver(); FluentWait<WebDriver> wait = new FluentWait<WebDriver>(driver) .withTimeout(timeout > -1 ? timeout : MAX_WAIT, TimeUnit.SECONDS) .pollingEvery(POLL_INTERVAL_MILLIS, TimeUnit.MILLISECONDS).ignoring(NoSuchElementException.class); try { return wait.until(ExpectedConditions.urlContains(text)); } catch (TimeoutException te) { logger.severe(format("Url did not contain text %s in time.", text)); } return false; }
From source file:org.awesomeagile.webapp.page.LandingPage.java
License:Apache License
public LandingPage loginWithGoogle(String endPoint) { driver.get(endPoint);//from w ww .j a v a2 s . c om wait.until(ExpectedConditions.visibilityOf(loginButton)); loginButton.click(); wait.until(ExpectedConditions.visibilityOf(googleButton)); googleButton.click(); wait.until(ExpectedConditions.urlContains(endPoint)); wait.until(ExpectedConditions.visibilityOf(userName)); return this; }
From source file:org.kitodo.selenium.testframework.pages.CurrentTasksEditPage.java
License:Open Source License
public void closeTask() throws Exception { closeTaskLink.click();//from w w w.java 2s .c o m await("Wait for 'confirm close' dialog to be displayed") .atMost(Browser.getDelayAfterDelete(), TimeUnit.MILLISECONDS).ignoreExceptions() .until(() -> confirmButton.isDisplayed()); confirmButton.click(); Thread.sleep(Browser.getDelayAfterDelete()); WebDriverWait wait = new WebDriverWait(Browser.getDriver(), 60); wait.until(ExpectedConditions.urlContains(Pages.getTasksPage().getUrl())); }
From source file:org.kitodo.selenium.testframework.pages.CurrentTasksEditPage.java
License:Open Source License
public void releaseTask() throws Exception { releaseTaskLink.click();//from ww w.ja v a 2 s. c om await("Wait for 'confirm release' dialog to be displayed") .atMost(Browser.getDelayAfterDelete(), TimeUnit.MILLISECONDS).ignoreExceptions() .until(() -> confirmButton.isDisplayed()); confirmButton.click(); Thread.sleep(Browser.getDelayAfterDelete()); WebDriverWait wait = new WebDriverWait(Browser.getDriver(), 60); wait.until(ExpectedConditions.urlContains(Pages.getTasksPage().getUrl())); }
From source file:org.kitodo.selenium.testframework.pages.Page.java
License:Open Source License
/** * Clicks a button which could be be stale, e.g. because of disabling and * enabling via Ajax. After click was performed, the browser waits for * redirecting to given url./*from w ww .j a va2 s . c om*/ * * @param button * the button to be clicked * @param url * the url to which is redirected after click */ protected void clickButtonAndWaitForRedirect(WebElement button, String url) { WebDriverWait webDriverWait = new WebDriverWait(Browser.getDriver(), 60); for (int attempt = 1; attempt < 4; attempt++) { try { await("Wait for button clicked").pollDelay(700, TimeUnit.MILLISECONDS).atMost(30, TimeUnit.SECONDS) .ignoreExceptions().until(() -> isButtonClicked.matches(button)); webDriverWait.until(ExpectedConditions.urlContains(url)); return; } catch (TimeoutException e) { logger.error("Clicking on button with id " + button.getAttribute("id") + " was not successful. Retrying now."); } } throw new TimeoutException("Could not access button: " + button.getAttribute("id") + "!"); }
From source file:org.kitodo.selenium.testframework.pages.Page.java
License:Open Source License
void deleteElement(String objectType, int removableID, int tabIndex, WebElement tabView) throws Exception { if (!isAt()) { goTo();//from w ww. ja va2 s. co m } switchToTabByIndex(tabIndex, tabView); Browser.getDriver() .findElement(By.xpath("//a[@href='/kitodo/pages/" + objectType.toLowerCase() + "Edit.jsf?id=" + removableID + "']/following-sibling::a[@id[contains(., 'delete" + objectType + "')]]")) .click(); await("Wait for 'confirm delete' dialog to be displayed") .atMost(Browser.getDelayAfterDelete(), TimeUnit.MILLISECONDS).ignoreExceptions() .until(() -> confirmRemoveButton.isDisplayed()); confirmRemoveButton.click(); Thread.sleep(Browser.getDelayAfterDelete()); WebDriverWait wait = new WebDriverWait(Browser.getDriver(), 60); wait.until(ExpectedConditions.urlContains(getUrl())); }
From source file:org.opennms.smoketest.CategoriesBoxIT.java
License:Open Source License
@Test public void testCategoryLink() throws Exception { // Hit the default "Network Interfaces" link on the startpage findElementByLink("Network Interfaces").click(); // check for correct url... wait.until(ExpectedConditions.urlContains("/opennms/rtc/category.jsp")); // ...and header cell findElementByXpath("//th[text()='24hr Availability']"); }