io.github.kgress.scaffold.webelements.DropDownWebElement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of framework Show documentation
Show all versions of framework Show documentation
Core components for Scaffold
package io.github.kgress.scaffold.webelements;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
import java.util.List;
import java.util.stream.Collectors;
/**
* A strongly typed representation of a DropDown {@link WebElement}.
*/
public class DropDownWebElement extends AbstractClickable {
public DropDownWebElement(By by) {
super(by);
}
public DropDownWebElement(String cssSelector) {
super(cssSelector);
}
public DropDownWebElement(By by, By parentBy) {
super(by, parentBy);
}
public DropDownWebElement(By by, WebElement parentElement) {
super(by, parentElement);
}
public DropDownWebElement(WebElement element) {
super(element);
}
/**
* Returns a list of options in the DropDown
*
* @return the list of options.
*/
public List getOptionsText() {
return getSelectElement().getOptions().stream()
.map(WebElement::getText)
.collect(Collectors.toList());
}
/**
* @param index the index to select
* @see Select#selectByIndex(int)
*/
public void selectByIndex(int index) {
getSelectElement().selectByIndex(index);
}
/**
* @param value the value to select
* @see Select#selectByIndex(int)
*/
public void selectByValue(String value) {
getSelectElement().selectByValue(value);
}
public String getValue() {
return getWebElement().getAttribute("value");
}
/**
* Sets the drop-down to the value contained in the visible of the {@literal
© 2015 - 2025 Weber Informatics LLC | Privacy Policy