Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

Difference Between findelement and findelements in Selenium Webdriver

Category: Selenium WebDriver

findElement () will return only single WebElement and if that element is not located or we use some wrong selector then it will throw NoSuchElement exception.

findElements() – FindElements in Selenium command takes in By object as the parameter and returns a list of web elements. It returns an empty list if there are no elements found using the given locator strategy and locator value.

WebElement demos=driver.findElement(By.xpath(""//*[@id='menu-top']/li[1]/a""));

List links=driver.findElements(By.xpath("".//*[@id='menu-top']/li""));

Leave a Reply

Your email address will not be published. Required fields are marked *