Am using Eclipse, TestNG and Selenium 2.32.
List <<f>WebElement> elementOption = driver.findElements(By.xpath("//li[@role='option']"));
The code driver.findElements(By.xpath("//li[@role='option']"));
returns all the elements which are not displayed as well. The above 'elementOption' now contains all the elements, even the elements that are not displayed in the webpage. We can use IsDisplayed
along with findElement
method which will return only the element which is displayed in the webpage. Is there anything similar to IsDisplayed
that can be used with findElements
which will return only the elements that are displayed?