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

net.thucydides.core.webelements.RadioButtonGroup Maven / Gradle / Ivy

package net.thucydides.core.webelements;

import com.google.common.base.Optional;
import org.openqa.selenium.WebElement;

import java.util.List;

public class RadioButtonGroup {

    private final List radioButtons;

    public RadioButtonGroup(List radioButtons) {
        this.radioButtons = radioButtons;
    }

    public Optional getSelectedValue() {
        for(WebElement radioButton : radioButtons) {
            if (radioButton.isSelected()) {
                return Optional.of(radioButton.getAttribute("value"));
            }
        }
        return Optional.absent();
    }

    public void selectByValue(String value) {
        for(WebElement radioButton : radioButtons) {
            if (value.equals(radioButton.getAttribute("value"))) {
                radioButton.click();
                break;
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy