Difference between findElement() and findElements() in Selenium? - TestingQ.com

-->Exclusive Portal for Testing Jobs

Difference between findElement() and findElements() in Selenium?

findElement():  It is used to find the first element in the current web page matching to the specified locator value.

Syntax:

WebElement element = driver.findElement(By.xpath("//*[@id='test']/div"));


findElements(): It is used to find all the elements in the current web page matching to the specified locator value and all the matching elements will be stored in the list as list of WebElements.

Syntax:

List<WebElement> elementList = driver.findElements(By.xpath("//*[@id='test']/div"));



To receive daily posted JOBS and Interview Questions
Just enter your email address below and click 'Submit'

Enter your email address:



Make sure to activate your subscription by clicking on the activation link sent to your email

No comments:

Post a Comment