Using Selenium Web driver in Java - trying to get all the values from a dropdown menu and storing to a list then checking if the given value is present in the list. If it is present then return true else false. I am new to selenium and learning things slowly kindly help me to resolve this issue. Thanks
public void verifyResults() {
Boolean found=false;
WebElement ele=driver.findElement(By.xpath("/html/body/div[1]/div/form/div[3]/div[1]/div[1]/div[2]/div/div[1]/div/div[2]/ul"));
Select sel = new Select(ele);
List<WebElement> el = sel.getOptions();
for(int i=0;i<el.size();i++){
if(el[i].Equals("Agra")) {
found=true;
break;
}
}
if(found){
System.out.println(ele.getText());
}
}