Example usage for org.openqa.selenium By tagName

List of usage examples for org.openqa.selenium By tagName

Introduction

In this page you can find the example usage for org.openqa.selenium By tagName.

Prototype

public static By tagName(String tagName) 

Source Link

Usage

From source file:com.easytox.automation.steps.addPhysicians.AddPhysiciansWestSteps.java

@When("^Click on the Phisician icon on the LabClient list page for Zest lab$")
public void click_on_the_Phisician_icon_on_the_LabClient_list_page_for_Zest_lab() throws Throwable {
    Thread.sleep(2000);/*from   w  w w . ja va2  s. com*/

    WebElement table = driver.findElement(By.id("example"));

    List<WebElement> allRows = table.findElements(By.tagName("tr"));
    loop: {
        for (WebElement row : allRows) {
            List<WebElement> cells = row.findElements(By.xpath("./*"));
            for (WebElement cell : cells) {
                String cellText = cell.getText();
                if (cellText.equals(LAB_CLIENT)) {
                    WebElement icon = row.findElement(By.cssSelector(".fa.fa-user-md.fa-2x"));
                    icon.click();
                    break loop;
                }
            }
        }
    }
    Thread.sleep(2000);
}

From source file:com.easytox.automation.steps.addPhysicians.AddPhysiciansWestSteps.java

@When("^Select 'Edit' icon next to 'BradLemon' physician$")
public void select_Edit_icon_next_to_BradLemon_physician() throws Throwable {
    Thread.sleep(2000);/*from  w w  w  .j av  a2s  .  c om*/

    WebElement table = driver.findElement(By.id("example"));
    List<WebElement> allRows = table.findElements(By.tagName("tr"));
    loop: {
        for (WebElement row : allRows) {
            List<WebElement> cells = row.findElements(By.xpath("./*"));
            for (WebElement cell : cells) {
                String cellText = cell.getText();
                if (cellText.equals("BradLemon")) {
                    WebElement icon = row.findElement(By.cssSelector(".fa.fa-pencil-square-o.fa-2x"));
                    icon.click();
                    break loop;
                }
            }
        }
    }
    Thread.sleep(2000);
}

From source file:com.easytox.automation.steps.AuditAndUserLogImpl.java

@Then("^Records should be displayed based on the ascending order of the selected column$")
public void check_ascending_order() {
    while (true) {
        try {/*w  ww.  j a v  a 2 s  . com*/
            WebElement table = driver.findElement(By.id(TABLE_LOCATOR));
            List<WebElement> allRows = table.findElements(By.tagName(ROWS_LOCATOR));
            int j;
            j = getSortColumn(allRows, 8);
            String temp = allRows.get(1).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText();

            checkData(temp, allRows, 2, j);
            break;
        } catch (StaleElementReferenceException ex) {
            System.out.println("element is not attached to the page document");
        }
    }
}

From source file:com.easytox.automation.steps.AuditAndUserLogImpl.java

@Then("^Records should be displayed based on the descending order of the selected column$")
public void check_descending_order() {
    int j;//  ww w .  j ava  2 s  . c o m

    WebElement table = driver.findElement(By.id(TABLE_LOCATOR));

    List<WebElement> allRows = table.findElements(By.tagName(ROWS_LOCATOR));

    j = getSortDescColumn(allRows, 8);

    String temp = allRows.get(1).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText();

    for (int i = 2; i < allRows.size(); i++) {
        int order = temp.toLowerCase()
                .compareTo(allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText().toLowerCase());
        Assert.assertTrue(order >= 0);
        temp = allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText();
    }
}

From source file:com.easytox.automation.steps.AuditAndUserLogImpl.java

@Then("^Records should be displayed based on the ascending order of the selected column.$")
public void check_ascending_order_of_the_selected_column() {
    while (true) {
        try {/*ww  w .  j  av  a 2  s  .c o m*/
            WebElement table = driver.findElement(By.id(TABLE_LOCATOR));
            List<WebElement> allRows = table.findElements(By.tagName(ROWS_LOCATOR));

            int j;
            j = getSortColumn(allRows, 6);
            String temp = allRows.get(1).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText();

            checkData(temp, allRows, 2, j);
            break;
        } catch (StaleElementReferenceException ex) {
            System.out.println("element is not attached to the page document");
        }
    }
}

From source file:com.easytox.automation.steps.AuditAndUserLogImpl.java

@Then("^Records should be displayed based on the descending order of the selected column.$")
public void check_descending_order_of_the_selected_column() {
    int j;//from w w  w. j a va  2s.  c om

    WebElement table = driver.findElement(By.id(TABLE_LOCATOR));

    List<WebElement> allRows = table.findElements(By.tagName(ROWS_LOCATOR));

    j = getSortDescColumn(allRows, 6);

    String temp = allRows.get(1).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText();

    for (int i = 2; i < allRows.size(); i++) {
        int order = temp.toLowerCase()
                .compareTo(allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText().toLowerCase());
        Assert.assertTrue(order >= 0);
        temp = allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText();
    }
}

From source file:com.easytox.automation.steps.LabClientImpl.java

@Then("^user should be able to view and select the options from the list and the corresponding (.*) of records should be displayed on the page$")
public void check_number_of_records(String number) {
    WebElement table = driver.findElement(By.id(TABLE_LOCATOR));
    int size = table.findElements(By.tagName(ROWS_LOCATOR)).size() - 1;

    WebElement element = driver.findElement(By.id(PAGINATE_LOCATOR));
    List<WebElement> list = element.findElements(By.tagName(LIST_LOCATOR));

    if (number.equals(ALL_NUMBER_OF_RECORDS)) {
        Assert.assertEquals(list.size(), 2);
    } else {//from   ww w .  jav  a 2 s .  co  m
        int num = Integer.parseInt(number);
        if (num <= size) {
            Assert.assertEquals(num, size);
        } else {
            Assert.assertEquals(list.size(), 3);
        }
    }
}

From source file:com.easytox.automation.steps.LabClientImpl.java

@Then("^Records should be displayed based on the ascending order of the selected field$")
public void check_ascending_order() {
    try {/* w w w .ja  v a  2 s .co  m*/
        int j;

        WebElement table = driver.findElement(By.id(TABLE_LOCATOR));

        List<WebElement> allRows = table.findElements(By.tagName(ROWS_LOCATOR));

        j = getSortColumn(allRows);

        String temp = allRows.get(1).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText();

        for (int i = 2; i < allRows.size(); i++) {
            if (temp.toLowerCase().contains(
                    allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText().toLowerCase())) {
                Assert.assertTrue(true);
            } else {
                int order = temp.toLowerCase().compareTo(
                        allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText().toLowerCase());
                Assert.assertTrue(order <= 0);
            }
        }
    } catch (StaleElementReferenceException ex) {
        check_ascending_order();
    }

}

From source file:com.easytox.automation.steps.LabClientImpl.java

@Then("^Records should be displayed based on the descending order of the selected field$")
public void check_descending_order() {
    int j;/*w w  w .  j a v a2 s  . c om*/

    WebElement table = driver.findElement(By.id(TABLE_LOCATOR));

    List<WebElement> allRows = table.findElements(By.tagName(ROWS_LOCATOR));

    j = getSortDescColumn(allRows);

    String temp = allRows.get(1).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText();

    for (int i = 2; i < allRows.size(); i++) {
        int order = temp.toLowerCase()
                .compareTo(allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText().toLowerCase());
        Assert.assertTrue(order >= 0);
    }
}

From source file:com.easytox.automation.steps.LabPhysicianImpl.java

@Then("^User should be able to view and select the options from the list and the corresponding (.*) of records should be displayed on the page$")
public void check_number_of_records(String number) {
    WebElement table = driver.findElement(By.id(TABLE_LOCATOR));
    int size = table.findElements(By.tagName(ROWS_LOCATOR)).size() - 1;

    WebElement element = driver.findElement(By.id(PAGINATE_LOCATOR));
    List<WebElement> list = element.findElements(By.tagName(LIST_LOCATOR));

    if (number.equals(ALL_NUMBER_OF_RECORDS)) {
        Assert.assertEquals(list.size(), 2);
    } else {//from  ww w.  ja  va  2  s  . c o m
        int num = Integer.parseInt(number);
        if (num > size) {
            Assert.assertEquals(list.size(), 3);
        } else {
            Assert.assertEquals(num, size);
        }
    }
}