WebDriver A = new FirefoxDriver();
A.get("http://www.gic.gov.lk/gic/index.php?option=com_findnearest&task=train");
WebElement From = A.findElement(By.id("startStation"));
List<WebElement> Options = From.findElements(By.tagName("option"));
System.out.println(Options.size());
for (int i = 0; i < Options.size(); i++) {
System.out.println(Options.get(i).getText() );
}
You can use this same example in any of your scenarios, Just change the link and the locator accordingly.
if we want to pass any value to the drop down to be selected then we can use the value given in the tag itself.
A.findElement(By.xpath("//*[@id='startStation']")).sendKeys("AGT");

When i execute the same code then below error occured in eclipse, why?
ReplyDeletethe type list is not generic it cannot be parameterized with arguments