Example usage for org.openqa.selenium.support.ui ExpectedConditions textToBePresentInElement

List of usage examples for org.openqa.selenium.support.ui ExpectedConditions textToBePresentInElement

Introduction

In this page you can find the example usage for org.openqa.selenium.support.ui ExpectedConditions textToBePresentInElement.

Prototype

public static ExpectedCondition<Boolean> textToBePresentInElement(final WebElement element, final String text) 

Source Link

Document

An expectation for checking if the given text is present in the specified element.

Usage

From source file:org.exoplatform.addons.portlets.springmvc.ContactsPortletTest.java

License:Open Source License

@Test
@RunAsClient/*ww w .  ja  v a2s.c  o m*/
public void testCreateNewContact() throws URISyntaxException, InterruptedException {
    // go directly to the new contact form page
    browser.get(portalURL.toString() + ";action=displayContactForm");

    WebElement newContactForm = browser.findElement(By.id("contactForm"));
    Assert.assertNotNull("Check that the New Contact form exists", newContactForm);

    // fill the form
    newContactForm.findElement(By.id("firstname")).sendKeys("Jack");
    newContactForm.findElement(By.id("lastname")).sendKeys("Johnson");
    newContactForm.findElement(By.id("displayName")).sendKeys("Jack Johnson");
    newContactForm.findElement(By.id("email")).sendKeys("jack.johnson@exoplatform.com");

    // click on the "Create" button
    WebElement validateNewContactButton = browser.findElement(By.id("validateNewContactButton"));
    Assert.assertNotNull("Check that the New Contact button exists", validateNewContactButton);
    validateNewContactButton.click();

    // check that the new contact is well created
    WebElement contactsList = browser.findElement(By.id("contactsList"));
    Assert.assertNotNull("Check that contacts list exists", contactsList);
    Assert.assertTrue("Check that Jack is listed",
            ExpectedConditions.textToBePresentInElement(contactsList, "Jack").apply(browser));
}

From source file:org.jtalks.tests.jcommune.webdriver.Users.java

License:Open Source License

private static void waitForEmailActivationInfoShowsUp() throws ValidationException {
    try {//  w  ww.  ja  va  2  s .  co m
        new WebDriverWait(driver, WAIT_FOR_DIALOG_TO_OPEN_SECONDS).until(
                ExpectedConditions.textToBePresentInElement(By.className("modal-body"), EMAIL_ACTIVATION_INFO));
    } catch (org.openqa.selenium.TimeoutException e) {
        throw new ValidationException();
    }
}

From source file:org.juzu.tutorial.juzcret.step7.JuZcretTestCase.java

License:Apache License

@Test
public void testLike() throws Exception {
    driver.get(getPortletURL().toString());

    // like/* w w w. j a v a  2 s.co  m*/
    WebElement likeBtn = driver.findElement(By.cssSelector(".btn-like"));
    likeBtn.click();

    // wait
    By selector = By.cssSelector(".btn-like .numb");
    ExpectedCondition<Boolean> condition = ExpectedConditions.textToBePresentInElement(selector, "1");
    assertTrue(new WebDriverWait(driver, 10).until(condition));
}

From source file:org.juzu.tutorial.juzcret.step7.JuZcretTestCase.java

License:Apache License

@Test
public void testComment() throws Exception {
    driver.get(getPortletURL().toString());
    WebElement body = driver.findElement(By.tagName("body"));
    assertFalse(body.getText().contains("test comment"));

    // input/*from w w w  . j a v a2 s .c o  m*/
    WebElement commentInput = driver.findElement(By.cssSelector(".secret-add-comment"));
    commentInput.sendKeys("test comment");
    // submit
    WebElement submitBtn = driver.findElement(By.cssSelector(".btn-comment"));
    submitBtn.click();
    // wait
    ExpectedCondition<Boolean> condition = ExpectedConditions
            .textToBePresentInElement(By.cssSelector(".secr-comments-list"), "test comment");
    assertTrue(new WebDriverWait(driver, 10).until(condition));
}

From source file:org.nuxeo.functionaltests.AbstractTest.java

License:Open Source License

/**
 * Fluent wait for text to be present in the element retrieved with the
 * given method.//from  w  w w .j  a  v  a  2 s.  co m
 *
 * @since 5.7.3
 */
public static void waitForTextPresent(By locator, String text) {
    Wait<WebDriver> wait = new FluentWait<WebDriver>(driver).withTimeout(LOAD_TIMEOUT_SECONDS, TimeUnit.SECONDS)
            .pollingEvery(POLLING_FREQUENCY_SECONDS, TimeUnit.SECONDS);
    wait.until(ExpectedConditions.textToBePresentInElement(locator, text));
}

From source file:org.nuxeo.functionaltests.ITSafeEditTest.java

License:Open Source License

private void checkSafeEditRestoreProvided() {
    // We must find the status message asking if we want to restore
    // previous unchanged data, and make sure it is visible
    Wait<WebDriver> wait = new FluentWait<WebDriver>(driver).withTimeout(5, TimeUnit.SECONDS)
            .pollingEvery(100, TimeUnit.MILLISECONDS).ignoring(NoSuchElementException.class);
    wait.until(ExpectedConditions.textToBePresentInElement(By.className("ambiance-title"),
            "A draft of this document has been saved"));
}

From source file:org.rstudio.studio.selenium.RConsoleInteraction.java

License:Open Source License

@Test
public void testInvokeHelp() {
    ConsoleTestUtils.resumeConsoleInteraction(driver_);
    Actions help = new Actions(driver_);
    help.sendKeys(Keys.ESCAPE + "?lapply" + Keys.ENTER);
    help.perform();//from w  w w  .j  a  v  a 2  s  .c o m

    // Wait for the Help window to activate
    final WebElement helpWindow = (new WebDriverWait(driver_, 5)).until(
            ExpectedConditions.presenceOfElementLocated(By.id(ElementIds.getElementId(ElementIds.HELP_FRAME))));

    // Wait for help to appear in the window
    Assert.assertEquals(helpWindow.getTagName(), "iframe");
    driver_.switchTo().frame(helpWindow);

    (new WebDriverWait(driver_, 5))
            .until(ExpectedConditions.textToBePresentInElement(By.tagName("body"), "lapply"));

    // Switch back to document context
    driver_.switchTo().defaultContent();
}

From source file:Pages.litecartShop.CartWidget.java

public void waitForCountUpdateTo(int value) {
    wait.until(ExpectedConditions.textToBePresentInElement(countProducts, String.valueOf(value)));
}

From source file:uk.ac.ebi.atlas.bioentity.widget.GenePageControllerBaselineWidgetGallusGallusSIT.java

License:Apache License

@Test
public void baselinePaneHasResults() {
    String widgetBody = subject.getBaselinePaneHeaderResultsMessage();
    assertThat(widgetBody, is("Results in tissues"));

    FluentWait wait = new WebDriverWait(driver, 10L).pollingEvery(1, TimeUnit.SECONDS);
    wait.until(ExpectedConditions.textToBePresentInElement(By.cssSelector(".bioEntityCardDifferentialSummary"),
            "Within Sample Abundance (Proteomics) > 0"));

    assertThat(subject.isBaselinePaneExpanded(), is(true));

    assertThat(subject.getGeneNames().size(), is(1));
    assertThat(subject.getGeneNames(), contains("Vertebrate tissues"));

}