Example usage for org.openqa.selenium WebElement getText

List of usage examples for org.openqa.selenium WebElement getText

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement getText.

Prototype

String getText();

Source Link

Document

Get the visible (i.e.

Usage

From source file:com.cengage.mindtap.keywords.searchPageAction.java

/**
 * Select search term.//from  w w w. ja  v  a2s  . c o m
 *
 * @param searchTerm the search term
 */
public void selectSearchTerm(String searchTerm) {
    waitForElementPresent("suggestion_box");
    searchTerm = searchTerm.toUpperCase();
    boolean flag = true;
    while (flag) {
        List<WebElement> suggestion_list = driver.findElements(By.xpath("//div[@class='hits']//ul/li"));
        for (WebElement searchItem : suggestion_list) {
            try {
                searchItem.findElement(By.xpath(".//div[@class='hit-highlights']")).click();
                System.out.println(searchItem.getText() + "Test Passed");
                flag = false;
                break;
            } catch (Exception e) {
                continue;
            }
        }
        //***** Click on Show More button if text not found ********
        if (flag = true) {
            System.out.println("Test Failing");
            try {
                //To avoid stale element exception
                driver.findElement(By.className("showMore"));
                element("showMore_btn").click();
            } catch (Exception e) {
                flag = false;
            }
        }
    }

    //******* Clear the search term from search box *************
    // clearSearchResult();
    //******* Hide the dock app *************
    //clickOnHideApp();
}

From source file:com.cengage.mindtap.keywords.SVRPageActions.java

/**
 * Verify presence of distinct activity.
 *
 * @param title the title/*  w ww . ja  v a  2 s. co  m*/
 * @return true, if successful
 */
boolean verifyPresenceOfDistinctActivity(String title) { /*TODO: Discuss moving this to AssignmentActivity.*/

    waitTOSync();
    List<WebElement> nb_list = driver.findElements(By.xpath("//div[@class='lpn_thumbTitle']/h3"));
    for (WebElement unit : nb_list) {
        String unitName = unit.getText();
        if (unitName.contains(title)) {
            return true;

        }
    }
    return false;
}

From source file:com.cengage.mindtap.keywords.SVRPageActions.java

void verifySpeechResultsInSVRWindow(String token) {
    List<WebElement> resultBlocks = driver
            .findElements(By.xpath("//li[contains(@ng-repeat,'activity.speech_type')]"));
    for (WebElement literal : resultBlocks) {
        String speech = literal.getText();
        assert speech.contains(token);
    }//www  . java2 s  .  c  o  m
}

From source file:com.cengage.mindtap.keywords.SVRPageActions.java

public void verifySupportingMaterialResultsInSVRWindow(String tag) {
    List<WebElement> outputBlocks = driver.findElements(
            By.xpath("//div[contains(.,'Supporting Materials:')]/ul[@class='activityAssetsList']"));
    for (WebElement textbox : outputBlocks) {
        String testline = textbox.getText().toLowerCase();
        assert testline.contains(tag);
    }//  ww  w  .  j  a v a2 s.  c o  m
}

From source file:com.cengage.mindtap.keywords.youSeeUPageActions.java

public boolean verifyPresenceOfDistinctYouSeeUActivityOnLPN(String data) {

    resetImplicitTimeout(10);//  w  w w .  j  a va  2 s .  c  om
    List<WebElement> nb_list = driver.findElements(By.xpath("//div[@class='lpn_thumbTitle']/h3"));
    for (WebElement unit : nb_list) {
        String unitName = unit.getText();
        if (unitName.contains(data)) {
            return true;
        }
    }
    return false;

}

From source file:com.cengage.mtx.keywords.MTXGradebookScoreVerificationPageAction.java

public WebElement getActivityFromListOfActivitiesInGradeBook(String activityName) {
    boolean flag = true;
    WebElement activityToBeReturned = null;
    int listSize;

    do {/*from   ww w.j ava  2 s  .c  o  m*/
        listSize = 0;
        listSize = driver.findElements(By.xpath("//span[contains(@class,'activity')]/parent::span")).size();
        //            System.out.println("Length of list" + listSize);
        for (WebElement activity : driver
                .findElements(By.xpath("//span[contains(@class,'activity')]/parent::span"))) {
            //                System.out.println("Activity Name:" + activity.getText());
            // BasePageActions.waitLong(1);
            if (activity.getText().contains(activityName)) {
                System.out.println("Activity Name Required" + activity.getText());
                flag = false;
                activityToBeReturned = activity;
                break;
            }
        }
        if (flag) {

            scrollDown(
                    driver.findElements(By.xpath("//span[contains(@class,'activity')]/parent::span")).get(10));
        }
    } while (flag);
    return activityToBeReturned;
}

From source file:com.cengage.mtx.keywords.MTXSearchPageAction.java

/**
 * Select search term./*from  w ww  . j ava2s  .  c o  m*/
 *
 * @param searchTerm the search term
 */
public void selectSearchTerm(String searchTerm) {
    waitForElementPresent("suggestion_box");

    searchTerm = searchTerm.toUpperCase();

    boolean flag = true;
    while (flag) {
        List<WebElement> suggestion_list = driver.findElements(By.xpath("//div[@class='name']"));
        for (WebElement searchItem : suggestion_list) {
            System.out.println(searchItem.getText());
            Assert.assertTrue(searchItem.getText().contains(searchTerm),
                    "Search term is not present in results");
            // searchItem.findElement(By.xpath(".//div[@class='info']/div[@class='name']")).click();
            flag = false;
            break;

        }

    }

    //******* Clear the search term from search box *************
    clearSearchResult();
    //******* Hide the dock app *************
    //clickOnHideApp();
}

From source file:com.cengage.mtx.keywords.MTXSearchPageAction.java

/**
 * Perform search operation and click on search button.
 *
 * @param name the name//www .  j a v a2 s .c  o m
 */
void performSearchOperationAndClickOnSearchButton(String name) {

    //By.cssSelector(".search")
    waitForElementPresent("inputSearch");
    element("inputSearch").clear();
    element("inputSearch").sendKeys(name);
    element("search_btn").click();
    wait.hardWait(2);
    List<WebElement> searchItem = driver.findElements(By.xpath("//div[@class='name']"));
    for (WebElement s : searchItem) {
        System.out.println("[DEBUG LOG]:" + s.getText());
        Assert.assertTrue(s.getText().contains(name), "Selected text is not present");
    }

    clearSearchResult();

}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

@Override
public List<String> findTextElements(String locator) {
    List<String> toReturn = new ArrayList<String>();
    for (WebElement w : webDriver.findElements(getSelector(locator))) {
        toReturn.add(w.getText());
    }/*  www .ja v  a  2 s . c  o m*/
    return toReturn;
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

@Override
public List<String> getAllText(String locator) {
    List<String> textList = new ArrayList<String>();
    List<WebElement> elements = webDriver.findElements(getSelector(locator));
    for (WebElement element : elements) {
        try {//from w  w  w  .  j  a  v  a2  s .  c  o  m
            textList.add(element.getText());
        } catch (Exception e) {
        }
    }
    return textList;
}