What is the difference between findElement and findElements in Selenium automation?

Please explain the difference between “findElement” and “findElements”.

Here is the difference between findElement and findElements in Selenium automation:

findElement(): This technique is used to find a single web element. When the element is found, it is returned as a WebElement object.

Let’s look at the syntax of findElement().

WebElement ele = driver.findElement(By.xpath(---xpath---); 

findElements(): It returns a list of WebElements that matches the locator defined in the method.

Let’s look at the syntax of findElements().

List<WebElement> ele = driver.findElements(By.xpath(---xpath---);
1 Like