0 votes
in Selenium by
When do we use findElement() and findElements()?

1 Answer

0 votes
by

findElement() is used to access any single element on the web page. It returns the object of the first matching element of the specified locator.

General syntax:

   WebElement element = driver.findElement(By.id(example));

findElements() is used to find all the elements in the current web page matching the specified locator value. All the matching elements would be fetched and stored in the list of Web elements.

General syntax:

   List <WebElement> elementList = driver.findElements(By.id(example));

...