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:org.wso2.es.ui.integration.test.store.ESStoreSearchGadgetListTestCase.java

License:Open Source License

@Test(groups = "wso2.es.store", description = "Search by newly added asset Name", dependsOnMethods = "testAddAsset")
public void testESStoreSearchNewlyAddedAssetsName() throws Exception {
    driver.get(baseUrl + "/store/pages/top-assets");
    driver.findElement(By.cssSelector("a.brand")).click();
    driver.findElement(By.cssSelector("i.icon-cog")).click();
    driver.findElement(By.cssSelector("i.icon-sort-down")).click();
    driver.findElement(By.id("search")).click();
    driver.findElement(By.name("overview_name")).clear();
    driver.findElement(By.name("overview_name")).sendKeys(assetName);
    new Select(driver.findElement(By.id("overview_category"))).selectByVisibleText(assetCategory);
    driver.findElement(By.id("search-button2")).click();
    driver.findElementPoll(By.linkText(assetName), 10);
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector("h4"), assetName));
    assertEquals(assetName, driver.findElement(By.cssSelector("h4")).getText(),
            "Newly added gadget is not found in the result of search by name : " + assetName);

}

From source file:org.wso2.es.ui.integration.test.store.ESStoreSearchGadgetListTestCase.java

License:Open Source License

@Test(groups = "wso2.es.store", description = "Search by newly added asset Version", dependsOnMethods = "testAddAsset")
public void testESStoreSearchNewlyAddedAssetsVersion() throws Exception {
    driver.get(baseUrl + "/store/pages/top-assets");
    driver.findElement(By.cssSelector("i.icon-cog")).click();
    driver.findElement(By.cssSelector("i.icon-sort-down")).click();
    driver.findElement(By.id("search")).click();
    driver.findElement(By.name("overview_version")).clear();
    driver.findElement(By.name("overview_version")).sendKeys(assetVersion);
    new Select(driver.findElement(By.id("overview_category"))).selectByVisibleText(assetCategory);
    driver.findElement(By.id("search-button2")).click();
    driver.findElementPoll(By.linkText(assetName), 10);
    wait.until(ExpectedConditions
            .textToBePresentInElementLocated(By.xpath("//h4[contains(.,'" + assetName + "')]"), assetName));
    assertEquals(assetName, driver.findElement(By.cssSelector("h4")).getText(),
            "Newly added gadget is not found in the result of search by version : " + assetVersion);
    wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("img")));
    driver.findElement(By.cssSelector("img")).click();
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.linkText("Description"), "Description"));
    assertEquals("Version 1.2.3", driver.findElement(By.cssSelector("small")).getText(),
            "Newly added gadget's version is incorrect in the store");
}

From source file:pawl.jbehave.step.BrowserSteps.java

License:Apache License

/**
 * Search text on the current page./*w w  w. ja  va2 s .c om*/
 *
 * @param text for search
 */
@Then("I get text '$text'")
@Alias("text '$text'")
public void verifySource(final String text) {
    browser.base().getWait().until(ExpectedConditions.textToBePresentInElementLocated(By.tagName("body"),
            Resources.base().string(text, text)));
}

From source file:test.nov21.configuration.AbstractPage.java

License:Open Source License

public void waitForTextPresent(final By by, String txt, int timeOut) {
    LOG.info("waiting for the text " + txt + " to be present... ");
    Wait<WebDriver> wait = new WebDriverWait(getDriver(), timeOut);
    wait.until(ExpectedConditions.textToBePresentInElementLocated(by, txt));
}

From source file:xbdd.stepdefs.AccessStepdefs.java

License:Apache License

@Then("^the user is prompted to enter user credentials again$")
public void the_user_is_prompted_to_enter_user_credentials_again() {
    new WebDriverWait(this.webDriver, 10).until(ExpectedConditions
            .textToBePresentInElementLocated(By.cssSelector(".text-plain"), "Please enter log-in details"));
}

From source file:xbdd.stepdefs.AccessStepdefs.java

License:Apache License

@Then("^the user cannot login$")
public void the_user_cannot_login() {
    new WebDriverWait(this.webDriver, 10).until(ExpectedConditions
            .textToBePresentInElementLocated(By.cssSelector(".form-error-text"), "Login attempt failed."));
}

From source file:xbdd.stepdefs.AccessStepdefs.java

License:Apache License

@Then("^the user can login$")
public void the_user_can_login() {
    new WebDriverWait(this.webDriver, 10)
            .until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector("h1"), "Welcome to XBDD"));
}

From source file:xbdd.stepdefs.AccessStepdefs.java

License:Apache License

@Then("^the user can access xbdd$")
public void the_user_can_access_xbdd() {
    this.webDriver.navigate().to(this.xbddInstance.getBaseURL());
    new WebDriverWait(this.webDriver, 10)
            .until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector("a"), "XBDD"));
}