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.keycloak.quickstart.ArquillianProfileJeeHtml5Test.java

License:Apache License

@Test
public void testLogin() throws InterruptedException {
    try {/*w  w  w. ja  v  a  2 s. co  m*/
        indexPage.clickLogin();
        loginPage.login("test-admin", "password");
        assertTrue(Graphene.waitGui()
                .until(ExpectedConditions.textToBePresentInElementLocated(By.id("username"), "admin")));
        profilePage.clickLogout();
    } catch (Exception e) {
        debugTest(e);
        fail("Should display logged in user");
    }
}

From source file:org.mousephenotype.www.testing.model.SearchFacetTable.java

License:Apache License

/**
 * Set the number of entries in the 'entries' drop-down box.
 * /*from   w w  w .j av  a  2 s  . c  o m*/
 * @param entriesSelect The new value for the number of entries to show.
 */
public void setNumEntries(EntriesSelect entriesSelect) {
    Select select = new Select(driver.findElement(byMap.get(TableComponent.BY_SELECT_GRID_LENGTH)));
    select.selectByValue(Integer.toString(entriesSelect.getValue()));
    wait.until(ExpectedConditions.textToBePresentInElementLocated(
            byMap.get(TableComponent.BY_SELECT_GRID_LENGTH), Integer.toString(entriesSelect.getValue())));
    TestUtils.sleep(3000); // trying to stop timing issues.
}

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

License:Apache License

/**
 * Fluent wait for text to be present in the element retrieved with the given method.
 *
 * @since 5.7.3//from  ww w  .j  a  v  a  2s  . c o m
 */
public static void waitForTextPresent(By locator, String text) {
    Wait<WebDriver> wait = getFluentWait();
    wait.until(ExpectedConditions.textToBePresentInElementLocated(locator, text));
}

From source file:org.owasp.webgoat.plugins.TestUtils.java

License:Open Source License

public static void assertTitlePresent(WebDriver webDriver, String title) {
    FluentWait<WebDriver> wait = new WebDriverWait(webDriver, 15); // wait for a maximum of 15 seconds
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("lesson-title"), title));
}

From source file:org.wso2.carbon.greg.publisher.lifecycles.CustomLifecycleUITestCase.java

License:Open Source License

@Test(groups = "wso2.greg", description = "comment and demote Lifecycle Operation by admin", dependsOnMethods = "testCommentAndPromote")
public void testCommentAndDemote() throws IOException, XPathExpressionException {
    WebDriverWait wait = new WebDriverWait(driver, WAIT_SECONDS);
    PublisherUtil asset = new PublisherUtil(driver);
    driver.findElement(By.xpath(uiElementMapper.getElement("publisher.promote.checkbox2.xpath"))).click();
    asset.addLCComment("going to demote");
    driver.findElement(By.id(uiElementMapper.getElement("publisher.demote"))).click();
    wait.until(ExpectedConditions.textToBePresentInElementLocated(
            By.cssSelector(uiElementMapper.getElement("publisher.lifecycle.alert")),
            "State updated successfully"));

    PublisherHomePage publisherHomePage = new PublisherHomePage(driver);
    publisherHomePage.logOut();// w  ww.  j av a  2  s  .  c o m
}

From source file:org.wso2.es.ui.integration.test.publisher.ESPublisherLCTransitionTestCase.java

License:Open Source License

@Test(groups = "wso2.es.publisher", description = "Testing LC transition")
public void testLc() throws Exception {
    //do a lc transition and check states
    driver.findElementPoll(By.linkText(assetName), MAX_POLL_COUNT);
    driver.findElement(By.linkText(assetName)).click();
    driver.findElement(By.id("LifeCycle")).click();
    driver.findElement(By.id("lifecycle-comment")).clear();
    driver.findElement(By.id("lifecycle-comment")).sendKeys("test");
    driver.findElement(By.id("lcActionPromote")).click();
    //        wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath
    //                ("//table[@id='lc-history']/tbody/tr/td[2]"), "admin changed the asset from Created to In-Review"));
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(".alert-success"),
            "State updated successfully"));
    assertEquals("admin moved asset from Created to In-Review", driver
            .findElement(By.xpath("/html/body/div/div[3]/div[3]/div/div[2]/div/div/div[1]/span[2]")).getText());
}

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

License:Open Source License

@Test(groups = "wso2.es.store", description = "Test Bookmarking")
public void testESStoreBookmarkTestCase() throws Exception {

    driver.get(baseUrl + STORE_GADGET_LIST_PAGE);
    //get the first element from the gadget list
    wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(
            By.cssSelector(".assets-container section div.ctrl-wr-asset:first-child a.ast-name")));
    String bookmarkedAsset = driver
            .findElement(By.cssSelector(".assets-container section div.ctrl-wr-asset:first-child a.ast-name"))
            .getText();// w w w  . ja va  2s .  co m
    driver.findElement(By.cssSelector(".assets-container section div.ctrl-wr-asset:first-child a.ast-name"))
            .click();

    //bookmark the asset
    wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.id("btn-add-gadget")));
    driver.findElement(By.id("btn-add-gadget")).click();

    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("btn-add-gadget"), "Bookmarked"));
    assertEquals("Bookmarked", driver.findElement(By.id("btn-add-gadget")).getText(), "Bookmarking failed");

    //check if shown in My Items page
    /*
            wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("div.ast-title a.ast-name")));
            assertEquals(bookmarkedAsset, driver.findElement(By.cssSelector("div.ast-title a.ast-name")).getText(),
        "Bookmarked asset not shown in My Items page");
            wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".bookmark-link")));
            driver.findElement(By.cssSelector(".bookmark-link")).click();
            */

}

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

License:Open Source License

@Test(groups = "wso2.es.store", description = "Search By Category Template", dependsOnMethods = "testESStoreSearchNewlyAddedAssetsName")
public void testStoreSearchByCategoryTemplate() 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();
    new Select(driver.findElement(By.id("overview_category"))).selectByVisibleText("Templates");
    driver.findElement(By.id("search-button2")).click();
    wait.until(ExpectedConditions/* w w  w .jav a 2 s .  c  om*/
            .not(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector("h4"), assetName)));
    assertEquals(6, driver.findElements(By.cssSelector("div.span3.asset")).size(),
            "Number of Template gadgets are incorrect");

}

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

License:Open Source License

@Test(groups = "wso2.es.store", description = "Search By Category-Google and Provider-Admin", dependsOnMethods = "testESStoreSearchNewlyAddedAssetsName")
public void testESStoreSearchGadgetByProviderAndCategory() throws Exception {
    driver.get(baseUrl + "/store/pages/top-assets?null");
    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_provider")).clear();
    driver.findElement(By.name("overview_provider")).sendKeys(adminUserName);
    driver.findElement(By.id("search-button2")).click();
    wait.until(ExpectedConditions//  w  ww.  j a va  2s  .c om
            .not(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector("h4"), assetName)));
    assertEquals(2, driver.findElements(By.cssSelector("div.asset-details")).size(),
            "Seach result count does not match");

}

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

License:Open Source License

@Test(groups = "wso2.es.store", description = "Search By Name- Bar Chart", dependsOnMethods = "testESStoreSearchNewlyAddedAssetsName")
public void testESStoreSearchAssetsByName() throws Exception {
    driver.get(baseUrl + "/store/pages/top-assets?null");
    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("Bar Chart");
    driver.findElement(By.id("search-button2")).click();
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector("h4"), "Bar Chart"));
    assertEquals("Bar Chart", driver.findElement(By.cssSelector("h4")).getText());
}