It is very important to know the difference between findElement() and findElements() functions and here you go for it :
findElement() :
- Find the first element within the current page using the given "locating mechanism".
- Returns a single WebElement.
- Syntax: WebElement findElement(By by)
Ex:
driver.get("https://signup.live.com"); WebElement firstName=driver.findElement(By.id("iFirstName")); firstName.sendKeys("Automated First Name");
findElements() :
- Find all elements within the current page using the given "locating mechanism".
- Returns List of WebElements.
- Syntax: java.util.List<WebElement> findElements(By by)
Ex:
driver.get("https://signup.live.com"); Listtextboxes1=driver.findElements(By.xpath("//input[@type='text']")); System.out.println("total textboxes "+textboxes1.size());
Good article!
ReplyDeleteGood Blog :)
ReplyDeleteYour information about selenium is really interesting. Also I
ReplyDeletewant to know the latest new techniques which are implemented in Selenium.
Please update it in your website.
Selenium
training Chennai
Nice job
ReplyDelete