Reputation: 859
i am trying to fetch all values from dropdown list using selenide .
using selectOptionByValue("0")
i can fetch one value.
But i need all values inside dropdown list.
Let me know how to do this using selenide code
Upvotes: 0
Views: 2187
Reputation: 194
You could use ElementsCollection:
ElementsCollection listOfElements = $$(By.cssSelector(".its_a_spicy_meatball"));
Note the two $
symbols - this denotes an the object as an ElementCollection
Example:
for(SelenideElement element : listOfElements){
element.click();
}
Upvotes: 0
Reputation: 64
Try this solution:
Select select = new Select($(By.id("<SELECT_ID>")));
List<WebElement> elements = select.getOptions();
Upvotes: 0
Reputation: 11
Maybe, you could try to use something like this:
$$(By.xpath("//path/to/element")).iterator().forEachRemaining(element -> {
/**
* your code here, describe here what to do with each element found by the xpath
* e.x.
* element.click();
*/
});
I used it to click through all links on the page with specific class
attribute.
Upvotes: 1