Automation Question:

Please explain what is the difference between findElement () and findElements ()?

Automation Interview Question
Automation Interview Question

Answer:

Both of them let user to find elements in the current web page matching to the specified locator value. But if you use findElement(), only the first matching element would be fetched. An example:

WebElement element = driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”))
If you use findElements(), the all matching elements would be fetched and stored in the WebElements list. An example:

List elementList = driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));


Previous QuestionNext Question
Tell us what Selenium components do you know?Explain me how can we capture screenshots in Selenium?