In my application, there is a drop down to select “Estimation Date”:
Please find below my test case. It is failing at the line where I am trying to select “Since”:
public class dropdown_issue {
GenericFunctions gf= new GenericFunctions();
@Test(enabled = true)
public void dropdown () throws InterruptedException{
System.setProperty(“webdriver.gecko.driver”,”D:\Selenium\BrowserDrivers\geckodriver.exe”);
WebDriver dr=new FirefoxDriver();
dr.get(“http://10.127.129.79:8080/abc”);
Thread.sleep(3000);
dr.findElement(By.id(“username”)).sendKeys(“user”);
dr.findElement(By.id(“password”)).sendKeys(“user”);
dr.findElement(By.xpath(“//button[@type=’submit’]”)).click();
WebElement est_date_dd= dr.findElement(By.xpath(“//div[@class=’clearfix’]//select[@name=’est-date’]”));
Select est_date= new Select(est_date_dd);
est_date.selectByValue(“Since”);
Thread.sleep(3000);
dr.quit();
}
}
Source: Read More