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

Tiugo image

Fast, Lean, and Fully Extensible

CKEditor 5 is built for developers who value flexibility and speed. Pick the features that matter, drop the ones that don’t and enjoy a high-performance WYSIWYG that fits into your workflow

Start now

Top comments (0)

Image of Stellar post

πŸš€ Stellar Dev Diaries Series: Episode 1 is LIVE!

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

πŸ‘‹ Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay