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

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

There is a newer version: 4.2.1
Show newest version
package net.thucydides.core.webelements;

import org.openqa.selenium.WebElement;

import java.util.List;
import java.util.Optional;

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.empty();
    }

    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