Sunday, March 22, 2015

Difference between findelement () and findelements ()..???

findElement :

 findElement method is used to locate single element .findelement method returns first matching element of given locator found on the web page . Return type is WebElement object. If no element found then it throw nosuchelement exception.

WebDriver driver = new internetExplorerDriver();
WebElement element = driver.findElement(by.ID("txtbox"));

findElements:

findelements method used to locate multiple element on web page with given attribute. like all the check boxes with same ID. Return type is list. if no element found then return empty list of webElement object.

List<WebElement> types= driver.findElements(By.xpath("//type")); 
int size = types.size();
 

No comments:

Post a Comment