0 votes
in Selenium by
When do we use findElement() and findElements()?

1 Answer

0 votes
by
When do we use findElement() and findElements()?

A. findElement()

It finds the first element in the current web page that matches the specified locator value.

Syntax:

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

B. findElements()

It finds all the elements in the current web page that matches the specified locator value.

Syntax:

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

Related questions

0 votes
asked Mar 31, 2021 in Selenium by sharadyadav1986
0 votes
asked Aug 22, 2019 in Selenium by john ganales
...