How To Test a DropDown Box
//Find the element(Drop Down) and Stored in WebElement
WebElement
c=f.findElement(By.id(""));
// Using Select class and now store the Webelement in Select class
Select h=new Select(c);
//Using Select by Index method select the option,index start from 0
Note:When less no of Options in Dropdown go with Select by index.
h.selectByIndex(3);
or
Note:When more no of Options in Dropdown go with Select by VisibleText.
h.selectByVisibleText("India");
or
Note:When test calendar dropdown or output values are number in the time use
Select by value.
h.selectByValue("1987");
WebElement
c=f.findElement(By.id("q3"));
Select h=new Select(c);
//h.selectByIndex(3);
//h.selectByVisibleText("Third
Option");
//h.selectByValue("1987");
No comments:
Post a Comment