0

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

praj
  • 849
  • 1
  • 16
  • 39

3 Answers3

1

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.

Chris Emerson
  • 13,041
  • 3
  • 44
  • 66
Ivan
  • 11
  • 2
0

Try this solution:

Select select = new Select($(By.id("<SELECT_ID>")));
List<WebElement> elements = select.getOptions();
Tunaki
  • 132,869
  • 46
  • 340
  • 423
0

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();
}
Michael Dally
  • 195
  • 3
  • 12