I am trying to use findElements method with a drop down.
I use the following line:
Select oSdropDown = new Select((WebElement)driver.findElements(By.id(“continents”)));
I have some more code below. If I use findElements, the code below is no longer executed, but if I use findElement it does. As I have read, findElements method returns all the elements to be found or only one if it is the case.
So does anybody know why the above situation?
I have found my answer for the above.
It seems that using the findElements method must be accompanied by explicitly use of get() method to fetch the first element.
So in this case, the above command will transform into: Select oSdropDown = new Select((WebElement)driver.findElements(By.id(“continents”)).get(0)); 🙂