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));

Related questions

0 votes
asked Mar 31, 2021 in Selenium by sharadyadav1986
0 votes
asked Aug 22, 2019 in Selenium by john ganales
...