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

com.sdl.selenium.extjs6.form.RadioGroup Maven / Gradle / Ivy

Go to download

Automated Acceptance Testing. Selenium and Selenium WebDriver test framework for web applications. (optimized for dynamic html, ExtJS, Bootstrap, complex UI, simple web applications/sites)

There is a newer version: 20.08.432.0_b2d2a09
Show newest version
package com.sdl.selenium.extjs6.form;

import com.sdl.selenium.web.SearchType;
import com.sdl.selenium.web.WebLocator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RadioGroup extends WebLocator {
    private static final Logger LOGGER = LoggerFactory.getLogger(RadioGroup.class);

    private Radio radio = new Radio(this);

    public RadioGroup() {
        setClassName("RadioGroup");
        setBaseCls("x-form-checkboxgroup");
    }

    public RadioGroup(WebLocator container) {
        this();
        setContainer(container);
    }

    public RadioGroup(WebLocator container, String label, SearchType... searchTypes) {
        this(container);
//        List search = Arrays.asList(searchTypes);
//        Collections.addAll(search, SearchType.DEEP_CHILD_NODE_OR_SELF);
//        SearchType[] types = search.toArray(new SearchType[search.size()]);
        WebLocator labelEl = new WebLocator().setTag("label").setText(label, searchTypes);
        setChildNodes(labelEl);
    }

    public boolean selectByLabel(String label) {
        return selectByLabel(label, SearchType.EQUALS);
    }

    public boolean selectByLabel(String label, SearchType... searchType) {
        radio.setLabel(label, searchType);
        boolean selected = radio.isSelected() || radio.click();
        radio.setLabel(null);
        return selected;
    }

    public boolean isSelectedByLabel(String label, SearchType... searchType) {
        radio.setLabel(label, searchType);
        boolean selected = radio.isSelected();
        radio.setLabel(null);
        return selected;
    }

    public String getLabelName(String label) {
        WebLocator locator = new WebLocator(radio).setElPath("/following-sibling::label[contains(text(),'" + label + "')]");
        return locator.getText();
    }

//    public boolean isDisabled() {
//        WebLocator locator = new WebLocator().setElPath(radio.getXPath(true));
//        return locator.exists();
//    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy