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.mroza.seleniumTests.KidProgramsViewTests.KidProgramsForPeriodViewPage.java

License:Open Source License

public void turnToProgramsForPeriodPagePart() {
    WebElement navigationArea = driver.findElement(By.className("ui-tabs-nav"));
    List<WebElement> navigationButtons = navigationArea.findElements(By.tagName("li"));
    for (WebElement navigationButton : navigationButtons) {
        if (navigationButton.findElement(By.tagName("a")).getText()
                .equals(Utils.getMsgFromResources("kidProgramsView.programsForPeriod"))) {
            navigationButton.click();/*from  ww  w.ja v  a2 s.  c  om*/
            break;
        }
    }
    SeleniumWaiter.waitForJQueryAndPrimeFaces(driver);
}

From source file:com.mroza.seleniumTests.KidProgramsViewTests.KidProgramsForPeriodViewPage.java

License:Open Source License

public List<String> getPeriodDateLabel() {
    List<WebElement> periodsDataLabels = driver.findElements(By.className("fc-title"));
    List<String> periodsDataLabelsText = new ArrayList<>();
    periodsDataLabels.forEach((element) -> periodsDataLabelsText.add(element.getText()));
    return periodsDataLabelsText;
}

From source file:com.mroza.seleniumTests.KidProgramsViewTests.KidProgramsForPeriodViewPage.java

License:Open Source License

private List<WebElement> getActualChosenPeriodDisplayAreaSpans() {
    WebElement form = getProgramsForPeriodFormContainer();
    WebElement outputPanel = form.findElement(By.className("ui-outputpanel"));
    return outputPanel.findElements(By.tagName("span"));
}

From source file:com.mroza.seleniumTests.KidProgramsViewTests.KidProgramsForPeriodViewPage.java

License:Open Source License

public void chooseProgram(String symbol) {
    WebElement dialog = getVisibleDialogBox();
    WebElement dialogContent = dialog.findElement(By.className("ui-dialog-content"));
    WebElement dialogForm = dialogContent.findElement(By.tagName("form"));
    WebElement tableWrapper = dialogForm.findElement(By.className("ui-datatable"))
            .findElement(By.className("ui-datatable-tablewrapper"));
    WebElement table = tableWrapper.findElement(By.tagName("table"));
    WebElement tableBody = table.findElement(By.tagName("tbody"));
    List<WebElement> tableRows = tableBody.findElements(By.tagName("tr"));

    for (WebElement tableRow : tableRows) {
        List<WebElement> tableColumns = tableRow.findElements(By.tagName("td"));
        if (tableColumns.get(0).getText().equals(symbol)) {
            tableColumns.get(2).findElement(By.tagName("button")).click();
            SeleniumWaiter.waitForJQueryAndPrimeFaces(driver);
            break;
        }//from www . j av  a  2s  .  co  m
    }
}

From source file:com.mroza.seleniumTests.KidProgramsViewTests.KidProgramsForPeriodViewPage.java

License:Open Source License

public void chooseTable(String name) {
    WebElement dialog = getVisibleDialogBox();
    WebElement dialogContent = dialog.findElement(By.className("ui-dialog-content"));
    WebElement dialogForm = dialogContent.findElement(By.tagName("form"));
    WebElement tableWrapper = dialogForm.findElement(By.className("ui-datatable"))
            .findElement(By.className("ui-datatable-tablewrapper"));
    WebElement table = tableWrapper.findElement(By.tagName("table"));
    WebElement tableBody = table.findElement(By.tagName("tbody"));
    List<WebElement> tableRows = tableBody.findElements(By.tagName("tr"));

    for (WebElement tableRow : tableRows) {
        List<WebElement> tableColumns = tableRow.findElements(By.tagName("td"));
        if (tableColumns.get(0).getText().equals(name)) {
            tableColumns.get(1).findElement(By.tagName("button")).click();
            SeleniumWaiter.waitForJQueryAndPrimeFaces(driver);
            break;
        }//ww  w  . j a  v  a  2  s.c om
    }
}

From source file:com.mroza.seleniumTests.KidProgramsViewTests.KidProgramsForPeriodViewPage.java

License:Open Source License

private WebElement getProgramsForPeriodFormContainer() {
    WebElement mainBody = driver.findElement(By.className("b-main-content"));
    WebElement tabs = mainBody.findElement(By.className("ui-tabs"));
    WebElement tabsPanel = tabs.findElement(By.className("ui-tabs-panels"));
    List<WebElement> panels = tabsPanel.findElements(By.className("ui-tabs-panel"));
    return panels.get(1).findElement(By.tagName("form"));
}

From source file:com.mroza.seleniumTests.KidProgramsViewTests.KidProgramsForPeriodViewPage.java

License:Open Source License

public String getActualChosenPeriodMessage() {
    WebElement form = getProgramsForPeriodFormContainer();
    WebElement outputPanel = form.findElement(By.className("ui-outputpanel"));
    return outputPanel.getText();
}

From source file:com.mroza.seleniumTests.KidProgramsViewTests.KidProgramsForPeriodViewPage.java

License:Open Source License

public void changeActualPeriodStartDate(Date date) {
    WebElement input = getPeriodDateInput(1);
    input.click();//from w  w  w. j  av a 2  s .c om
    SeleniumWaiter.waitForJQueryAndPrimeFaces(driver);
    setDatePickerForProperMonth(date);

    int dayOfMonth = getPartOfDate(date, Calendar.DAY_OF_MONTH);
    WebElement datePicker = driver.findElement(By.className("ui-datepicker-calendar"));
    List<WebElement> calendarFields = datePicker.findElements(By.tagName("td"));

    for (WebElement calendarField : calendarFields) {
        List<WebElement> calendarFieldValues = calendarField.findElements(By.tagName("a"));
        if (calendarFieldValues.size() > 0) {
            String chosenDay = calendarFieldValues.get(0).getText();
            if (chosenDay.equals(String.valueOf(dayOfMonth))) {
                calendarField.click();
                break;
            }
        }
    }
    SeleniumWaiter.waitForJQueryAndPrimeFaces(driver);
}

From source file:com.mroza.seleniumTests.KidProgramsViewTests.KidProgramsForPeriodViewPage.java

License:Open Source License

private void setDatePickerForProperMonth(Date date) {
    WebElement dataPickerPrev = driver.findElement(By.className("ui-datepicker-prev"));
    WebElement dataPickerNext = driver.findElement(By.className("ui-datepicker-next"));

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);/*from  ww  w . j av a  2s  . c  o  m*/

    int month = calendar.get(Calendar.MONTH);

    calendar.setTime(new Date());
    int currentMonth = calendar.get(Calendar.MONTH);

    if (currentMonth > month)
        dataPickerPrev.click();
    else if (currentMonth < month)
        dataPickerNext.click();
}

From source file:com.mroza.seleniumTests.KidProgramsViewTests.KidProgramsViewPage.java

License:Open Source License

public void setSearchValue(String symbol) {
    WebElement searchBoxInput = driver.findElement(By.className("ui-inputtext"));
    searchBoxInput.sendKeys(symbol);/*  w  ww  .ja va2s. c  om*/
    SeleniumWaiter.waitForJQueryAndPrimeFaces(driver);
}