Hi Nilaabh, Selenium Webdriver uses findElement and findElements methods to find locators of any web element. Now the difference between them is that the findElement command takes in the By object as the parameter and returns an object of type WebElement.
By object in turn can be used with various locator strategies such as ID, Name, Class Name, XPATH etc. This method throws exception NoSuchElementException if there are no elements matching the locator. Following is the syntax of findElement command in Selenium web driver:
WebElement elementName = driver.findElement(By.LocatorStrategy("LocatorValue"));
While, findElements command takes in By object as the parameter and returns a list of web elements. It returns an empty list if there are no elements found using the given locator strategy and locator value. Returns an empty list if there are no web elements matching the locator strategy. Below is the syntax of findElements command:
List<WebElement> elementName = driver.findElements(By.LocatorStrategy("LocatorValue"));