com.sdl.selenium.bootstrap.form.MultiSelect Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Testy Show documentation
Show all versions of Testy Show documentation
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.bootstrap.form;
import com.sdl.selenium.utils.config.WebDriverConfig;
import com.sdl.selenium.web.WebLocator;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import java.util.ArrayList;
import java.util.List;
/**
* Used for finding element process (to generate xpath address)
* Example:
* {@code
*
*
*
*
*
* }
* In Java write this:
* {@code
* MultiSelect multiSelect = new MultiSelect().setLabel("Source:");
* multiSelect.select("Cheese", "Tomatoes");
* }
*/
public class MultiSelect extends SelectPicker {
public MultiSelect() {
super.setClassName("MultiSelect");
}
public MultiSelect(WebLocator container) {
this();
setContainer(container);
}
public MultiSelect(WebLocator container, String label) {
this(container);
setLabel(label);
}
@Override
public boolean select(String value) {
super.select(value);
click();
return true;
}
public boolean select(String... values) {
click();
for (String value : values) {
super.doSelect(value);
}
// WebLocator shadow = new WebLocator().setClasses("dropdown-backdrop");
click();
return true;
}
public List getValueSelected() {
click();
List list = new ArrayList<>();
WebLocator group = new WebLocator().setClasses("btn-group", "open");
WebLocator li = new WebLocator(group).setTag("li").setCls("active");
WebLocator label = new WebLocator(li).setTag("label");
label.ready();
List elements = WebDriverConfig.getDriver().findElements(By.xpath(label.getXPath()));
for (WebElement element : elements) {
String text = element.getText();
list.add(text);
}
click();
return list;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy