Please explain what is the difference between findElement () and findElements ()?
Submitted by: MuhammadBoth 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”));
Submitted by: Muhammad
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”));
Submitted by: Muhammad
Read Online Automation Job Interview Questions And Answers
Top Automation Questions
☺ | What is Selenium? |
☺ | Tell me does the Selenium have any limitations? |
☺ | Tell me what is an Absolute XPath? |
☺ | Explain me what the WebDriver supported Mobile Testing Drivers do you know? |
☺ | Tell us what is the alternate way to click on login button? |
Top Testing Categories
☺ | Manual Testing Interview Questions. |
☺ | Rational TestSuite Interview Questions. |
☺ | QTP Interview Questions. |
☺ | Database Testing Interview Questions. |
☺ | Software QA Interview Questions. |