How to Count No of Countries in Dropdwon box Using Selenium Code:
- To Find Out no of countries in Dropdown box Using getOptions Method is better.
- Using Select class to find the Element
- Using List concept and get the options from Dropdown.
public class noodropdown {
public static void main(String[] args)
{
// TODO Auto-generated method stub
WebDriver g=new FirefoxDriver();
g.manage().window().maximize();
g.get("");
Select s=new Select(g.findElement(By.id()));
List<WebElement> f=s.getOptions();
System.out.println(“no of links
is:”f.size());
for(int i=0;i<f.size();i++)
{
System.out.println(f.get(i).getText());
}
}
}
No comments:
Post a Comment