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

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

Introduction

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

Prototype

public static ExpectedCondition<Boolean> textToBePresentInElementLocated(final By locator, final String text) 

Source Link

Document

An expectation for checking if the given text is present in the element that matches the given locator.

Usage

From source file:com.liferay.faces.test.Icefaces4PortletTest.java

License:Open Source License

@Test
@RunAsClient/*ww  w  .j av  a  2s .  c o  m*/
@InSequence(1500)
public void dataEntry() throws Exception {

    String foo = "";

    logger.log(Level.INFO, "clicking into the firstNameField ...");
    firstNameField.click();
    logger.log(Level.INFO, "tabbing into the next field ...");
    firstNameField.sendKeys(Keys.TAB);

    logger.log(Level.INFO, "firstNameField.getAttribute('value') = " + firstNameField.getAttribute("value"));
    logger.log(Level.INFO,
            "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath));

    if (isThere(browser, firstNameFieldErrorXpath)) { // houston we have a problem
        logger.log(Level.INFO, "firstNameFieldError.isDisplayed() = " + firstNameFieldError.isDisplayed());
        assertFalse(
                "firstNameFieldError should not be displayed after simply tabbing out of the empty field, having never entered any data.  "
                        + "But we see '" + firstNameFieldError.getText() + "'",
                firstNameFieldError.isDisplayed());
    }

    logger.log(Level.INFO, "Shift tabbing back into the firstNameField ...");
    (new Actions(browser)).keyDown(Keys.SHIFT).sendKeys(Keys.TAB).keyDown(Keys.SHIFT).perform();

    logger.log(Level.INFO,
            "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath));

    logger.log(Level.INFO, "entering 'asdf' into the firstNameField and then tabbing out of it...");
    firstNameField.sendKeys("asdf");
    firstNameField.sendKeys(Keys.TAB);

    logger.log(Level.INFO, "firstNameField.getAttribute('value') = " + firstNameField.getAttribute("value"));
    logger.log(Level.INFO,
            "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath));
    assertTrue("The data 'asdf' should be in the firstNameField after tabbing out of it",
            "asdf".equals(firstNameField.getAttribute("value")));

    logger.log(Level.INFO, "Shift tabbing back into the firstNameField ...");
    (new Actions(browser)).keyDown(Keys.SHIFT).sendKeys(Keys.TAB).keyUp(Keys.SHIFT).perform();

    firstNameField.click();
    logger.log(Level.INFO,
            "clearing the firstNameField using the BACKSPACE key, and then tabbing out of the firstNameField ...");
    firstNameField.sendKeys(Keys.BACK_SPACE);

    logger.log(Level.INFO, "Waiting for the firstNameField to contain 'asd' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(firstNameFieldXpath), "asd"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, firstNameFieldXpath)) {
            foo = firstNameField.getText();
        }
        logger.log(Level.INFO, "firstNameField.getText() = " + firstNameField.getText());
        assertTrue(
                "firstNameField should contain 'asd', but " + firstNameFieldXpath + " contains '" + foo + "'.",
                false);
    }

    firstNameField.sendKeys(Keys.BACK_SPACE);

    logger.log(Level.INFO, "Waiting for the firstNameField to contain 'as' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(firstNameFieldXpath), "as"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, firstNameFieldXpath)) {
            foo = firstNameField.getText();
        }
        assertTrue(
                "firstNameField should contain 'as', but " + firstNameFieldXpath + " contains '" + foo + "'.",
                false);
    }

    firstNameField.sendKeys(Keys.BACK_SPACE);

    logger.log(Level.INFO, "Waiting for the firstNameField to contain 'a' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(firstNameFieldXpath), "a"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, firstNameFieldXpath)) {
            foo = firstNameField.getText();
        }
        assertTrue("firstNameField should contain 'a', but " + firstNameFieldXpath + " contains '" + foo + "'.",
                false);
    }

    firstNameField.sendKeys(Keys.BACK_SPACE);

    logger.log(Level.INFO, "Waiting for the firstNameField to contain '' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(firstNameFieldXpath), ""));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, firstNameFieldXpath)) {
            foo = firstNameField.getText();
        }
        assertTrue("firstNameField should contain '', but " + firstNameFieldXpath + " contains '" + foo + "'.",
                false);
    }

    firstNameField.sendKeys(Keys.TAB);

    logger.log(Level.INFO, "Waiting for the firstNameFieldError to contain 'Value is required' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(firstNameFieldErrorXpath),
                "Value is required"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        assertTrue("firstNameFieldError should be visible after tabbing out with no value," + " but "
                + firstNameFieldErrorXpath + " is not visible.", false);
    }

    logger.log(Level.INFO, "firstNameField.getAttribute('value') = " + firstNameField.getAttribute("value"));
    assertTrue(
            "The data 'asdf' should no longer be in the firstNameField after clearing it out with BACK_SPACE and then tabbing out.   "
                    + "But we see '" + firstNameField.getAttribute("value") + "'",
            "".equals(firstNameField.getAttribute("value")));
    logger.log(Level.INFO,
            "isThere(browser, firstNameFieldErrorXpath) = " + isThere(browser, firstNameFieldErrorXpath));
    assertTrue(
            "The firstNameFieldError should at least be in the DOM somewhere by this point, but it is not there",
            isThere(browser, firstNameFieldErrorXpath));
    logger.log(Level.INFO, "firstNameFieldError.getText() = " + firstNameFieldError.getText());
    assertTrue("The firstNameFieldError should say 'Value is required'",
            firstNameFieldError.getText().contains("Value is required"));

}

From source file:com.liferay.faces.test.Icefaces4PortletTest.java

License:Open Source License

@Test
@RunAsClient/*  ww w  . j  a  va2 s.c  o m*/
@InSequence(2000)
public void validateEmail() throws Exception {

    String foo = "";

    // checks an invalid email address
    logger.log(Level.INFO, "Entering an invalid email address 'test' ...");
    emailAddressField.sendKeys("test");
    phoneNumberField.click();

    logger.log(Level.INFO, "Waiting for the emailAddressFieldError to contain 'Invalid e-mail address' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(emailAddressFieldErrorXpath),
                "Invalid e-mail address"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        assertTrue("emailAddressField should be visible after tabbing out with no value," + " but "
                + emailAddressFieldErrorXpath + " is not visible.", false);
    }
    logger.log(Level.INFO,
            "emailAddressField.getAttribute('value') = " + emailAddressField.getAttribute("value"));

    assertTrue("Invalid e-mail address validation message displayed",
            emailAddressFieldError.getText().contains("Invalid e-mail address"));
    logger.log(Level.INFO, "emailAddressFieldError.isDisplayed() = " + emailAddressFieldError.isDisplayed());
    logger.log(Level.INFO, "emailAddressFieldError.getText() = " + emailAddressFieldError.getText());

    // checks a valid email address
    logger.log(Level.INFO, "Waiting for the emailAddressFieldError to contain '' ...");
    try {
        emailAddressField.clear();
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(emailAddressFieldXpath), ""));
        logger.log(Level.INFO, "emailAddressField.getText() = '" + emailAddressField.getText() + "'");
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, emailAddressFieldXpath)) {
            foo = emailAddressField.getText();
        }
        assertTrue("emailAddressField should be clear," + " but " + emailAddressFieldXpath + " contains '" + foo
                + "'", false);
    }

    logger.log(Level.INFO, "Entering a valid email address 'test@liferay.com' ...");
    emailAddressField.click();
    emailAddressField.sendKeys("test@liferay.com");
    emailAddressField.sendKeys(Keys.TAB);
    phoneNumberField.click();

    logger.log(Level.INFO, "Waiting for the emailAddressFieldError to contain 'test@liferay.com' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(emailAddressFieldXpath),
                "test@liferay.com"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, emailAddressFieldXpath)) {
            foo = emailAddressField.getText();
        }
        assertTrue("emailAddressField should contain 'test@liferay.com'," + " but " + emailAddressFieldXpath
                + " contains '" + foo + "'", false);
    }

    logger.log(Level.INFO, "Waiting for the emailAddressFieldError to disappear ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(emailAddressFieldErrorXpath)));
        logger.log(Level.INFO,
                "emailAddressField.getAttribute('value') = " + emailAddressField.getAttribute("value"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, emailAddressFieldErrorXpath)) {
            foo = emailAddressFieldError.getText();
        }
        assertTrue("emailAddressFieldError should NOT be visible after entering 'test@liferay.com'," + " but "
                + emailAddressFieldErrorXpath + " is still there showing '" + foo + "'", false);
    }

}

From source file:com.liferay.faces.test.Icefaces4PortletTest.java

License:Open Source License

@Test
@RunAsClient/* w  w w  .jav a  2s  .com*/
@InSequence(8000)
public void dateValidation() throws Exception {

    String foo = "";

    // checks an invalid dateOfBirth
    try {
        dateOfBirthField.clear();
        logger.log(Level.INFO, "No exceptions occured when clearing the dateOfBirthField");
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        assertTrue(
                "No exceptions should occur when clearing the dateOfBirthField, but one did occur with the following message: "
                        + e.getMessage(),
                false);
    }

    logger.log(Level.INFO, "Waiting for the dateOfBirthField to contain '' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(dateOfBirthFieldXpath), ""));
        logger.log(Level.INFO, "after clearing dateOfBirthField.getAttribute('value') = "
                + dateOfBirthField.getAttribute("value"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, dateOfBirthFieldErrorXpath)) {
            foo = dateOfBirthFieldError.getText();
        }
        assertTrue("dateOfBirthField should be empty after clearing," + " but " + dateOfBirthFieldXpath
                + " contains '" + foo + "'.", false);
    }

    logger.log(Level.INFO, "Entering an invalid value for the date of birth ... 12/34/5678 ...");
    dateOfBirthField.sendKeys("12/34/5678");

    logger.log(Level.INFO, "Waiting for the dateOfBirthField to contain '12/34/5678' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(dateOfBirthFieldXpath),
                "12/34/5678"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, dateOfBirthFieldErrorXpath)) {
            foo = dateOfBirthFieldError.getText();
        }
        assertTrue("dateOfBirthField should contain '12/34/5678'," + " but " + dateOfBirthFieldXpath
                + " contains '" + foo + "'.", false);
    }

    submitButton.click();

    logger.log(Level.INFO, "Waiting for the dateOfBirthFieldError to contain 'Invalid date format' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(dateOfBirthFieldErrorXpath),
                "Invalid date format"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        assertTrue("dateOfBirthFieldError should be visible after submitting with '12/34/5678'," + " but "
                + dateOfBirthFieldErrorXpath + " is not visible.", false);
    }

    logger.log(Level.INFO,
            "dateOfBirthField.getAttribute('value') = " + dateOfBirthField.getAttribute("value"));
    logger.log(Level.INFO, "dateOfBirthFieldError.isDisplayed() = " + dateOfBirthFieldError.isDisplayed());
    logger.log(Level.INFO, "dateOfBirthFieldError.getText() = " + dateOfBirthFieldError.getText());
    assertTrue(
            "dateOfBirthFieldError should contain 'Invalid date format', but insteead contains '"
                    + dateOfBirthFieldError.getText() + "'",
            dateOfBirthFieldError.getText().contains("Invalid date format"));

    // checks with no dateOfBirth
    dateOfBirthField.clear();

    logger.log(Level.INFO, "Waiting for the dateOfBirthField to contain '' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(dateOfBirthFieldXpath), ""));
        logger.log(Level.INFO, "after clearing dateOfBirthField.getAttribute('value') = "
                + dateOfBirthField.getAttribute("value"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, dateOfBirthFieldErrorXpath)) {
            foo = dateOfBirthFieldError.getText();
        }
        assertTrue("dateOfBirthField should be empty after clearing," + " but " + dateOfBirthFieldXpath
                + " contains '" + foo + "'.", false);
    }

    phoneNumberField.click();

    logger.log(Level.INFO, "Waiting for the dateOfBirthFieldError to contain 'Value is required' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(dateOfBirthFieldErrorXpath),
                "Value is required"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        assertTrue(
                "dateOfBirthFieldError should be visible after entering '12/34/5678' and clicking into another field,"
                        + " but " + dateOfBirthFieldErrorXpath + " does not contain 'Value is required'.",
                false);
    }

    logger.log(Level.INFO,
            "dateOfBirthField.getAttribute('value') = " + dateOfBirthField.getAttribute("value"));
    logger.log(Level.INFO, "dateOfBirthFieldError.isDisplayed() = " + dateOfBirthFieldError.isDisplayed());
    logger.log(Level.INFO, "dateOfBirthFieldError.getText() = " + dateOfBirthFieldError.getText());

    // checks a valid dateOfBirth
    foo = "";
    dateOfBirthField.clear();

    logger.log(Level.INFO, "Waiting for the dateOfBirthField to contain '' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(dateOfBirthFieldXpath), ""));
        logger.log(Level.INFO, "after clearing dateOfBirthField.getAttribute('value') = "
                + dateOfBirthField.getAttribute("value"));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, dateOfBirthFieldErrorXpath)) {
            foo = dateOfBirthFieldError.getText();
        }
        assertTrue("dateOfBirthField should be empty after clearing," + " but " + dateOfBirthFieldXpath
                + " contains '" + foo + "'.", false);
    }

    logger.log(Level.INFO, "Entering a valid dateOfBirth = 01/02/3456 ...");
    dateOfBirthField.sendKeys("01/02/3456");
    logger.log(Level.INFO, "Clicking into the phoneNumberField ...");
    phoneNumberField.click();

    logger.log(Level.INFO, "Waiting for the dateOfBirthFieldError to disappear ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(dateOfBirthFieldErrorXpath)));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, dateOfBirthFieldErrorXpath)) {
            foo = dateOfBirthFieldError.getText();
        }
        assertTrue("dateOfBirthFieldError should NOT be visible after entering 01/02/3456," + " but "
                + dateOfBirthFieldErrorXpath + " is still there showing '" + foo + "'", false);
    }

}

From source file:com.liferay.faces.test.Icefaces4PortletTest.java

License:Open Source License

@Test
@RunAsClient//w  w  w  .  j av  a  2  s.c  o m
@InSequence(9000)
public void submitAndValidate() throws Exception {

    String foo = "";
    logger.log(Level.INFO, "clearing fields ...");

    logger.log(Level.INFO, "Waiting for the dateOfBirthField to show on the page ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(dateOfBirthFieldXpath)));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        assertTrue("dateOfBirthField should be visible after fileUpload," + " but " + dateOfBirthFieldXpath
                + " is not visible.", false);
    }

    try {
        dateOfBirthField.clear();
        logger.log(Level.INFO, "No exceptions occured when clearing the dateOfBirthField");
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
    }

    emailAddressField.clear();
    postalCodeField.clear();

    if (isThere(browser, hideCommentsLinkXpath)) {
        waitForElement(browser, "//textarea[contains(@id,':comments')]");
    }
    int commentsTextAreas = browser.findElements(By.xpath("//textarea[contains(@id,':comments')]")).size();
    logger.log(Level.INFO, "# of commentsTextAreas = " + commentsTextAreas);

    if (commentsTextAreas == 0) { // if comments were not previously exercised, then we may need to show the
        // comments text area.
        try {
            waitForElement(browser, showCommentsLinkXpath);
        } catch (Exception e) {
            logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
            assertTrue(
                    "showCommentsLinkXpath should be visible when their is no text area for comments showing,"
                            + " but the " + showCommentsLinkXpath + " is not visible.",
                    e == null);
        }

        showCommentsLink.click();

        logger.log(Level.INFO, "Waiting for the comments textrea to show on the page ...");
        try {
            WebDriverWait wait = new WebDriverWait(browser, 10);
            wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(commentsXpath)));
        } catch (Exception e) {
            logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
            assertTrue("comments textarea should be visible after clicking 'Show Comments'," + " but "
                    + commentsXpath + " is not visible.", false);
        }

        commentsTextAreas = browser.findElements(By.xpath(commentsXpath)).size();
        logger.log(Level.INFO, "# of commentsTextAreas = " + commentsTextAreas);
    }

    assertTrue("The commentsTextArea should be showing, but it is not visible.", commentsTextAreas == 1);

    comments.clear();

    logger.log(Level.INFO, "Waiting for the emailAddressField to show on the page ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(emailAddressFieldXpath)));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        assertTrue("emailAddressField should be visible after clearing comments field," + " but "
                + emailAddressFieldXpath + " is not visible.", false);
    }

    logger.log(Level.INFO, "fields were cleared now, but let's see ...");
    logger.log(Level.INFO,
            "emailAddressField.getAttribute('value') = " + emailAddressField.getAttribute("value"));
    assertTrue("emailAddressField is empty after clearing and clicking into another field",
            "".equals(emailAddressField.getAttribute("value")));

    logger.log(Level.INFO, "entering data ...");
    firstNameField.sendKeys("David");
    lastNameField.sendKeys("Samuel");
    emailAddressField.sendKeys("no_need@just.pray");
    phoneNumberField.sendKeys("(way) too-good");

    try {
        dateOfBirthField.sendKeys("01/02/3456");
        logger.log(Level.INFO, "No exceptions occured when entering the dateOfBirthField");
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
    }

    postalCodeField.sendKeys("32801");
    logger.log(Level.INFO, "Clicking into phone number field ...");
    phoneNumberField.click();

    logger.log(Level.INFO, "Waiting for the commentsXpath to show on the page ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(commentsXpath)));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        assertTrue("comments should be visible after clicking into the phoneNumberField," + " but "
                + commentsXpath + " is not visible.", false);
    }

    String genesis11 = "Indeed the people are one and they all have one language, and this is what they begin to do ...";
    comments.sendKeys(genesis11);

    logger.log(Level.INFO, "Waiting for the comments to contain '" + genesis11 + "' ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementValue(By.xpath(commentsXpath), genesis11));
        logger.log(Level.INFO, "comments.getText() = " + comments.getText());
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        if (isThere(browser, commentsXpath)) {
            foo = comments.getText();
        }
        assertTrue("comments should be correct after entering," + " but " + commentsXpath + " contains '" + foo
                + "'.", false);
    }

    // asserting correct data is still there
    assertTrue(
            "asserting that firstNameField.getText().equals('David'), " + "but it is '"
                    + firstNameField.getAttribute("value") + "'",
            firstNameField.getAttribute("value").equals("David"));
    assertTrue(
            "asserting that lastNameField.getText().equals('Samuel'), " + "but it is '"
                    + lastNameField.getAttribute("value") + "'",
            lastNameField.getAttribute("value").equals("Samuel"));
    assertTrue(
            "asserting that emailAddressField.getText().equals('no_need@just.pray'), " + "but it is '"
                    + emailAddressField.getAttribute("value") + "'",
            emailAddressField.getAttribute("value").equals("no_need@just.pray"));
    assertTrue(
            "asserting that phoneNumberField.getText().equals('(way) too-good'), " + "but it is '"
                    + phoneNumberField.getAttribute("value") + "'",
            phoneNumberField.getAttribute("value").equals("(way) too-good"));
    assertTrue(
            "asserting that dateOfBirthField.getText().equals('01/02/3456'), " + "but it is '"
                    + dateOfBirthField.getAttribute("value") + "'",
            dateOfBirthField.getAttribute("value").equals("01/02/3456"));
    assertTrue(
            "asserting that postalCodeField.getText().equals('32801'), " + "but it is '"
                    + postalCodeField.getAttribute("value") + "'",
            postalCodeField.getAttribute("value").equals("32801"));
    assertTrue("asserting that comments.getText().equals(genesis11), " + "but it is '"
            + comments.getAttribute("value") + "'", comments.getAttribute("value").equals(genesis11));

    logger.log(Level.INFO, "Correct data asserted.  Clicking submit button ...");
    submitButton.click();

    logger.log(Level.INFO, "Waiting for the text 'Dear ' to show on the page ...");
    try {
        WebDriverWait wait = new WebDriverWait(browser, 10);
        wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(formTagXpath), "Dear "));
    } catch (Exception e) {
        logger.log(Level.INFO, "Exception e.getMessage() = " + e.getMessage());
        assertTrue("formTag should contain 'Dear '," + " but " + formTagXpath + " does not contain 'Dear '.",
                false);
    }
}

From source file:com.liferay.faces.test.selenium.browser.internal.BrowserDriverImpl.java

License:Open Source License

@Override
public void waitForTextPresentInElement(String text, String elementXpath, boolean elementMustBeDisplayed) {

    logger.info("Waiting for text \"{}\" to be present in element {}.", text, elementXpath);

    By byXpath = By.xpath(elementXpath);
    ExpectedCondition<?> expectedCondition = ExpectedConditions.textToBePresentInElementLocated(byXpath, text);
    expectedCondition = ExpectedConditionsUtil.ifNecessaryExpectElementDisplayed(expectedCondition,
            elementMustBeDisplayed, byXpath);
    waitFor(expectedCondition);//from   ww  w .java 2s .c  o  m
    logger.info("Text \"{}\" is present in Element {}.", text, elementXpath);
}

From source file:com.liferay.faces.test.selenium.browser.internal.WaitingAsserterImpl.java

License:Open Source License

@Override
public void assertTextNotPresentInElement(String text, String elementXpath, boolean elementMustBeDisplayed) {

    By byXpath = By.xpath(elementXpath);
    ExpectedCondition<?> expectedCondition = ExpectedConditions
            .not(ExpectedConditions.textToBePresentInElementLocated(byXpath, text));
    expectedCondition = ExpectedConditionsUtil.ifNecessaryExpectElementDisplayed(expectedCondition,
            elementMustBeDisplayed, byXpath);
    assertTrue(expectedCondition);/*from w  ww .  j  a v a 2s .  c om*/
}

From source file:com.liferay.faces.test.selenium.browser.internal.WaitingAsserterImpl.java

License:Open Source License

@Override
public void assertTextPresentInElement(String text, String elementXpath, boolean elementMustBeDisplayed) {

    By byXpath = By.xpath(elementXpath);
    ExpectedCondition<?> expectedCondition = ExpectedConditions.textToBePresentInElementLocated(byXpath, text);
    expectedCondition = ExpectedConditionsUtil.ifNecessaryExpectElementDisplayed(expectedCondition,
            elementMustBeDisplayed, byXpath);
    assertTrue(expectedCondition);/*from ww w .j a  v  a2  s .  c  o m*/
}

From source file:com.oracle.amc.sqe.util.webui.WebUIPage.java

License:Open Source License

public void waitText(By by, String str) {
    wait.until(ExpectedConditions.textToBePresentInElementLocated(by, str));
}

From source file:com.pivotal.gemfire.tools.pulse.tests.PulseBaseTests.java

License:Open Source License

public void verifyTextPresrntById(String id, String text) {
    WebDriverWait wait = (WebDriverWait) new WebDriverWait(driver, maxWaitTime, 500);
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id(id), text));
}

From source file:com.pivotal.gemfire.tools.pulse.tests.PulseBaseTests.java

License:Open Source License

public void verifyTextPresrntByXpath(String xpath, String text) {
    WebDriverWait wait = (WebDriverWait) new WebDriverWait(driver, maxWaitTime, 500);
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(xpath), text));
}