Saturday, 23 January 2016

How to print the all value from drop down box in selenium




By using ID:

List<WebElement> allText=new Select(driver1.findElement(By.id(getId("ID1")))).getOptions();
int i=0;
for(webElement ele:allText)
{
System.out.println(ele.get(i).getText());
i++;
}



By using xpath :


List<WebElement> allText = driver.findElements(By.xpath("//*[@id="vehicleTypeName"]/option"));
int i=0;
for(webElement ele:allText)
{
System.out.println(ele.get(i).getText());
i++;
}

No comments:

Post a Comment