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

com.sdl.selenium.web.form.MultipleSelect 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)

The newest version!
package com.sdl.selenium.web.form;

import com.sdl.selenium.web.SearchType;
import com.sdl.selenium.web.WebLocator;
import org.openqa.selenium.WebElement;

import java.util.ArrayList;
import java.util.List;

public class MultipleSelect extends ComboBox {

    public MultipleSelect() {
        setClassName("MultipleSelect");
    }

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

    public MultipleSelect(WebLocator container, String label) {
        this(container);
        setLabel(label);
    }

    public boolean selectRows(String... values) {
        return selectRows(SearchType.EQUALS, values);
    }


    public boolean selectRows(SearchType searchType, String... values) {
        boolean select = false;
        if (ready()) {
            for (String value : values) {
                WebLocator el = new WebLocator(this).setText(value, searchType);
                select = el.click();
            }
        }
        return select;
    }

    /**
     *
     * @return if return null, then component is not ready
     */
    public List getValues() {
        List list = null;
        if (ready()) {
            list = new ArrayList<>();
            for (WebElement element : findElements()) {
                list.add(element.getText());
            }
        }
        return list;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy