This blog is for Automation Test Engineers

Saturday, 2 September 2017

Search specified option present in list box

WebDriver driver=new FirefoxDriver()'
driver.get("https://www.facebook.com/");
WebElement Day=driver.findElement(By.id("day"));
Select sel=new Select(Day);
List<WebElement>list=sel.getOption();
System.out.println(list);
for(int i=0;i<list.size();i++){
String s=list.get(i).getText();
if(s.contains("16")){
System.out.print("found");
s.click();
break;//includes duplicate option 

}}

0

0 comments:

Post a Comment