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.denimgroup.threadfix.selenium.pages.ApplicationDetailPage.java

License:Mozilla Public License

public int scanCount() {
    WebElement scanTab;
    try {//from  www .  ja  va2s. c om
        scanTab = driver.findElementById("scanTabLink");
    } catch (NoSuchElementException e) {
        return 0;
    }

    String scanText = scanTab.getText().trim();
    Pattern pattern = Pattern.compile("^\\s*(\\d+)");
    Matcher matcher = pattern.matcher(scanText);
    if (matcher.find()) {
        return Integer.parseInt(matcher.group(1));
    }
    return -1;
}

From source file:com.denimgroup.threadfix.selenium.pages.DefectTrackerIndexPage.java

License:Mozilla Public License

private int getIndex(String roleName) {
    int i = -1;/* w w  w  . j  av a 2  s.c o  m*/
    for (WebElement name : names) {
        i++;
        String text = name.getText().trim();
        if (text.equals(roleName.trim())) {
            return i;
        }
    }
    return -1;
}

From source file:com.denimgroup.threadfix.selenium.pages.TeamDetailPage.java

License:Mozilla Public License

public boolean isTextPresentInApplicationsTableBody(String text) {
    for (WebElement element : applicationsTableBody.findElements(By.xpath(".//tr/td/a"))) {
        if (element.getText().contains(text)) {
            lastItemFoundInApplicationsTableBodyLink = element;
            return true;
        }//from w  w  w .  j a va 2  s .  c om
    }
    return false;
}

From source file:com.denimgroup.threadfix.selenium.pages.TeamIndexPage.java

License:Mozilla Public License

public int getIndex(String teamName) {
    int i = -1;/*from   w w w  .j a v a2 s .co m*/
    List<WebElement> names = new ArrayList<WebElement>();
    for (int j = 1; j <= getNumTeamRows(); j++) {
        names.add(driver.findElementById("teamName" + j));
    }
    for (WebElement name : names) {
        i++;
        String text = name.getText().trim();
        if (text.equals(teamName.trim())) {
            return i;
        }
    }
    names = new ArrayList<WebElement>();
    for (int j = 1; j <= getNumTeamRows(); j++) {
        names.add(driver.findElementById("teamName" + j));
    }
    for (WebElement name : names) {
        i++;
        String text = name.getText().trim();
        if (text.equals(teamName.trim())) {
            return i;
        }
    }
    return -1;
}

From source file:com.denimgroup.threadfix.selenium.pages.TeamIndexPage.java

License:Mozilla Public License

public int getAppIndex(String appName) {
    int i = -1;//from  w w w. jav  a 2  s  . c  om
    for (WebElement app : apps) {
        i++;
        String text = app.getText().trim();
        if (text.equals(appName.trim())) {
            return i;
        }
    }
    return -1;
}

From source file:com.denimgroup.threadfix.selenium.pages.UploadScanPage.java

License:Mozilla Public License

public List<String> getChannelSelectContents() {
    List<WebElement> loc = channelSelect.getOptions();
    List<String> businesses = new ArrayList<String>();
    for (WebElement el : loc) {
        businesses.add(el.getText());
    }// www  . jav a 2  s .  c o m
    return businesses;
}

From source file:com.denimgroup.threadfix.selenium.pages.WafIndexPage.java

License:Mozilla Public License

public int getIndex(String roleName) {
    int i = -1;/*from  w  w w.ja  va  2 s.  c  om*/
    for (int j = 1; j <= getNumRows(); j++) {
        names.add(driver.findElementById("wafName" + j));
    }
    for (WebElement name : names) {
        i++;
        String text = name.getText().trim();
        if (text.equals(roleName.trim())) {
            return i;
        }
    }
    return -1;
}

From source file:com.denimgroup.threadfix.selenium.pages.WafRulesPage.java

License:Mozilla Public License

public boolean isTextPresentInApplicationsTableBody(String text) {
    if (isElementPresent("applicationsTableBody")) {
        for (WebElement element : driver.findElementById("applicationsTableBody")
                .findElements(By.xpath(".//tr/td/a"))) {
            if (element.getText().contains(text)) {
                lastItemFoundInApplicationsTableBodyLink = element;
                return true;
            }/*from   ww w .  ja v  a  2  s. co m*/
        }
    }

    return false;
}

From source file:com.DFATPageObjects.MyApplications.Step1_Personal_PageObjects.java

public boolean errorChecker(WebDriver Driver, String Path, String Section, int Errors)
        throws IOException, InterruptedException {
    try {//from  w w  w .j a  v a 2 s .  c  om
        int count = 0;
        click(SaveAndContinueButton);
        Thread.sleep(1000);
        List<WebElement> ErrorList = new ArrayList<WebElement>();
        ErrorList = Driver.findElements(By.xpath("//span[contains(@id,'-error')]"));
        BaseClass.myWriteAppend(Path, "");
        BaseClass.myWriteAppend(Path, Section);
        BaseClass.myWriteAppend(Path, "");
        //System.out.println("Error Message list");
        for (WebElement errrors : ErrorList) {
            if (!errrors.getText().isEmpty()) {
                BaseClass.myWriteAppend(Path, "Error Text " + (count + 1) + ":" + errrors.getText());
                //System.out.println("Error Text "+(count+1)+":"+errrors.getText());
                count = count + 1;
            }
        }
        System.out.println("Expected " + Errors + " Errors and Found " + count);
        BaseClass.myWriteAppend(Path, "");
        BaseClass.myWriteAppend(Path, "Expected " + Errors + " Errors and Found " + count);
        if (!(count == Errors)) {
            System.out.println("Number of error Messages Inconsistant.");
            return false;

        }
        BaseClass.myWriteAppend(Path, "***********************************");
        BaseClass.myWriteAppend(Path, "");
        return true;
    } catch (Exception e) {
        return false;
    }

}

From source file:com.dhenton9000.selenium.d3.D3Tests.java

private void gotoD3Page() {

    this.getAutomation().maximizeWindow();

    WebElement backboneD3Link = this.getAutomation()
            .findElement(GenericAutomationRepository.SELECTOR_CHOICE.partialLinkText, "Backbone and D3");
    backboneD3Link.click();//from w w w .  j a v  a  2 s  .c o m

    this.getAutomation().getWaitMethods().waitForElementToBeClickable(2, SELECTOR_CHOICE.linkText, "D3 Demos");

    WebElement d3Hover = getAutomation().findElement(SELECTOR_CHOICE.linkText, "D3 Demos");

    assertNotNull(d3Hover);
    assertEquals("D3 Demos", d3Hover.getText());
    this.getAutomation().hoverOn(d3Hover);

    this.getAutomation().getWaitMethods().waitForElementToBeClickable(2, SELECTOR_CHOICE.linkText, "Tree Demo");

    this.getAutomation().findElement(SELECTOR_CHOICE.linkText, "Tree Demo").click();

}