Example usage for org.openqa.selenium By className

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

Introduction

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

Prototype

public static By className(String className) 

Source Link

Document

Find elements based on the value of the "class" attribute.

Usage

From source file:com.moodle.testmanager.pageObjectModel.SiteAdministration.java

License:GNU General Public License

/**
 * Clicks Save changes button.
 */
public void clickSaveChanges() {
    WebElement button = driver.findElement(By.className("form-submit"));
    button.click();
}

From source file:com.mroza.seleniumTests.EditProgramViewTests.EditProgramViewPage.java

License:Open Source License

public List<String> getTablesNamesListContent() {
    WebElement tableAreaContent = getTableArea();
    List<WebElement> tablesList = getTablesList();
    if (tablesList.size() == 0)
        return new ArrayList<String>() {
            {// w  w  w  . j  a  v a2 s . com
                add(tableAreaContent.getText());
            }
        };

    List<String> tablesHeaders = new ArrayList<>();
    for (WebElement table : tablesList) {
        WebElement tableHeader = table.findElement(By.className("ui-datatable-header"));
        tablesHeaders.add(tableHeader.getText());
    }
    return tablesHeaders;
}

From source file:com.mroza.seleniumTests.EditProgramViewTests.EditProgramViewPage.java

License:Open Source License

private WebElement getTableArea() {
    WebElement tableArea = driver.findElement(By.className("ui-datagrid"));
    return tableArea.findElement(By.className("ui-datagrid-content"));
}

From source file:com.mroza.seleniumTests.EditProgramViewTests.EditProgramViewPage.java

License:Open Source License

public void inputTableName(String tableName) {
    WebElement table = getTableWithHeader("", true);
    WebElement tableHeader = table.findElement(By.className("ui-datatable-header"));
    tableHeader.findElement(By.tagName("input")).sendKeys(tableName);
    SeleniumWaiter.waitForJQueryAndPrimeFaces(driver);
}

From source file:com.mroza.seleniumTests.EditProgramViewTests.EditProgramViewPage.java

License:Open Source License

public void changeTableName(String tableName, String oldTableName) {
    WebElement table = getTableWithHeader(oldTableName, true);
    WebElement tableHeader = table.findElement(By.className("ui-datatable-header"));
    tableHeader.findElement(By.tagName("input")).clear();
    tableHeader.findElement(By.tagName("input")).sendKeys(tableName);
    SeleniumWaiter.waitForJQueryAndPrimeFaces(driver);
}

From source file:com.mroza.seleniumTests.EditProgramViewTests.EditProgramViewPage.java

License:Open Source License

public void setUpTableContentHeader(String tableName, int teachingNumber, int generalizationNumber) {
    WebElement table = getTableWithHeader(tableName, true);
    WebElement tableContent = table.findElement(By.className("ui-datatable-tablewrapper"));
    WebElement tableContentHeader = tableContent.findElement(By.tagName("thead"));
    List<WebElement> tableContentHeaderColumns = tableContentHeader.findElements(By.className("checkbox-cell"));
    for (WebElement tableContentHeaderColumn : tableContentHeaderColumns) {
        if (tableContentHeaderColumn.findElement(By.className("ui-column-title")).getText().equals("U:")) {
            setUpHeaderParameter(tableContentHeaderColumn, teachingNumber);
        }/*from   w  w  w .  j  av a 2 s  .  co  m*/
        if (tableContentHeaderColumn.findElement(By.className("ui-column-title")).getText().equals("G:")) {
            setUpHeaderParameter(tableContentHeaderColumn, generalizationNumber);
        }
    }

}

From source file:com.mroza.seleniumTests.EditProgramViewTests.EditProgramViewPage.java

License:Open Source License

public List<String> getTableRowsNamesForTable(String newTableName, Boolean isEditing) {
    WebElement table = getTableWithHeader(newTableName, isEditing);
    WebElement tableContent = table.findElement(By.className("ui-datatable-tablewrapper"));
    WebElement tableContentRowsArea = tableContent.findElement(By.tagName("tbody"));
    List<WebElement> tableRows = tableContentRowsArea.findElements(By.tagName("tr"));
    List<String> tableRowNames = new ArrayList<>();
    for (WebElement tableRow : tableRows) {
        List<WebElement> tableRowColumns = tableRow.findElements(By.tagName("td"));
        if (isEditing) {
            tableRowNames.add(tableRowColumns.get(0).findElement(By.tagName("input")).getAttribute("value"));
        } else {// w w w .java  2s  .  c  o m
            tableRowNames.add(tableRowColumns.get(0).getText());
        }
    }
    return tableRowNames;
}

From source file:com.mroza.seleniumTests.EditProgramViewTests.EditProgramViewPage.java

License:Open Source License

private List<WebElement> getTablesList() {
    WebElement tableAreaContent = getTableArea();
    return tableAreaContent.findElements(By.className("ui-datagrid-row"));
}

From source file:com.mroza.seleniumTests.EditProgramViewTests.EditProgramViewPage.java

License:Open Source License

private WebElement getTableWithHeader(String header, Boolean isEditing) {
    List<WebElement> tablesList = getTablesList();
    for (WebElement table : tablesList) {
        WebElement tableHeader = table.findElement(By.className("ui-datatable-header"));
        if (isEditing) {
            WebElement tableHeaderInput = tableHeader.findElement(By.tagName("input"));
            if (tableHeaderInput.getAttribute("value").equals(header))
                return table;
        } else if (tableHeader.getText().equals(header))
            return table;
    }//ww  w  . j  av  a2 s .com
    return null;
}

From source file:com.mroza.seleniumTests.EditProgramViewTests.EditProgramViewPage.java

License:Open Source License

private WebElement getRowForTable(String tableName, String rowName, Boolean isEditing) {
    WebElement table = getTableWithHeader(tableName, isEditing);
    WebElement tableContent = table.findElement(By.className("ui-datatable-tablewrapper"));
    WebElement tableContentRowsArea = tableContent.findElement(By.tagName("tbody"));
    List<WebElement> tableRows = tableContentRowsArea.findElements(By.tagName("tr"));
    for (WebElement tableRow : tableRows) {
        List<WebElement> tableRowColumns = tableRow.findElements(By.tagName("td"));

        if (isEditing) {
            if (tableRowColumns.get(0).findElement(By.tagName("input")).getAttribute("value").equals(rowName)) {
                return tableRow;
            }// w w w. ja  v a  2  s . co  m
        } else {
            if (tableRowColumns.get(0).getText().equals(rowName)) {
                return tableRow;
            }
        }

    }
    return null;
}