DEV Community

Cover image for πŸ›‘ Difference Between FindElement and FindElements in Selenium.πŸ›‘
Pramod Dutta
Pramod Dutta

Posted on β€’ Edited on

2 2

πŸ›‘ Difference Between FindElement and FindElements in Selenium.πŸ›‘

βœ… Join us - https://sendfox.com/thetestingacademy

In this video, We are going to Difference Between FindElement and FindElements in Selenium.

Selenium defines two methods for identifying web elements:

  • findElement: A command used to uniquely identify a web element within the web page.
  • find elements: A command used to identify a list of web elements within the web page.

 FindElement and FindElements

βœ… Download Code - https://scrolltest.com/automation/day24

βœ…FindElement ()

  • Find a Single element
  • If Element is not found - NoSuchElement exception. Return only single WebElement
driver.get(β€œhttps://katalon-demo-cura.herokuapp.com/β€œ);
 WebElement demos=driver.findElement(by.id(β€œbtn-make-appointment”));

βœ… FindElements()

  • Find multiple elements with xpath/css
  • Return List of WebElements - Returns an empty list if no matching element is found
 driver.get(β€œhttps://katalon-demo-cura.herokuapp.com/β€œ);
 List<WebElement>  ptags=driver.findElements(By.tagName(β€œp”));

--
Be sure to subscribe for more videos like this!

 TheTestingAcademy

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Sentry image

See why 4M developers consider Sentry, β€œnot bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more