1.

Explain the difference between findElement() and findElements() in Selenium.

Answer»

Following is the major difference between the two commands:

1.findElement(): command is USED for finding a PARTICULAR element on a web PAGE, it is used to return an object of the first FOUND element by the locator. Eg:

WebElement element = driver.findElement(By.id(example));

2. findElements(): command is used for finding all the elements in a web page specified by the locator value. The return type of this command is the list of all the MATCHING web elements. Eg: 

List <WebElement> elementList = driver.findElements(By.id(example));


Discussion

No Comment Found