All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.serenitybdd.core.pages.FluentDropdownSelect Maven / Gradle / Ivy

There is a newer version: 4.2.8
Show newest version
package net.serenitybdd.core.pages;

import org.openqa.selenium.WebElement;

public class FluentDropdownSelect extends FluentDropdown {

    public FluentDropdownSelect(WebElementFacade webElementFacade) {
       super(webElementFacade);
    }

    public void byVisibleText(String text) {
        selectByVisibleText(text);
    }

    public void byIndex(int index) {
        selectByIndex(index);
    }

    public void byValue(String value) {
        selectByValue(value);
    }

    public void all() {
        getOptions().forEach(
                option -> setSelected(option, true)
        );
    }

    private void setSelected(WebElement option, boolean select) {
        if (option.isSelected() != select) {
            option.click();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy