Difference Between FindElement And FindElements Methods

To automate a web application using Selenium WebDriver, we need to locate the elements on a web page. We use different locators depends on our needs to find the elements. Here is a link to the post “Locators in Selenium“. In this post, we discuss two methods to find the elements on a webpage namely findElement and findElements methods.

Let’s see the detailed overview – difference between findElement and findElements methods.

The difference between findElement and findElements methods:


findElement method is used to access a single web element on a page. It returns the first matching element. It throws a NoSuchElementException exception when it fails to find If the element.



findElements method returns the list of all matching elements. The findElement method throws a NoSuchElementException exception when the element is not available on the page. Whereas, the findElements method returns  an empty list when the element is not available or doesn’t exist on the page. It doesn’t throw NoSuchElementException.


Let’s see a practical example – FindElement and FindElements methods in Selenium WebDriver:

FindElement method:

FindElements method:

Difference between FindElement And FindElements Methods

Sumasri is a Sr. Software Test Engineer. Currently working in an MNC. She is a co-founder of Software Testing Material. She has an exclusive experience in the field of Software Testing. She writes here about Manual Testing and Automation Testing.

3 thoughts on “Difference Between FindElement And FindElements Methods”

  1. List link = driver.findElements(By.xpath(“//*[@id=’rso’]/div/div/div/h3/a”));

    should be like this otherwise it ill show type mismatch issue.

    List link = driver.findElements(By.xpath(“//*[@id=’rso’]/div/div/div/h3/a”));

    • Whats your point Ashish. I didnt get you.

  2. if i want to know
    1. total no. of links present
    2. text of any nth link
    then how to code?

Leave a Comment

Share via
Copy link
Powered by Social Snap