Difference between findElement and findElements ?


 

findElement findElements
It is used for Working with single object/Element It is used for Working with Multiple object/Element
Object's/Element's property is Always Unique Object's/Element's property Not Unique( Common Property Used)
For Example driver.findElemet(By.name("q"))
Here name is unique which is for single element
For Example driver.findElemets(By.tagName("a"))
Here tagname is for all available hyperlinks which will return mulltiple elements in list format
Return type is WebElement Return type is List<WebElement>
NoSuchElementException is thrown when Object is not found with specified locator No Exception is thrown when Object is not found with specified locator (Returns empty list)

Comments