seleniumdropdownlistfor

Having issue in selecting drop down element under makemytrip website


Having issue in selecting drop down element under the following website

http://flights.makemytrip.com/makemytrip/fareCal.do?intid=NewHP_to_DF_FC_Menu

I'm unable to select any one of the cities listed below. Please help me out resolving the same.

Scenarios Tried

driver.findElement(By.className("chzn-single")).click();

driver.findElement(By.xpath("//span[contains,'NewDelhi']")).click();

driver.findElement(By.xpath("//span[@id='fromcity_chzn']")).click();

Solution

  • This works:

        WebElement leavingFrom = driver.findElement(By.xpath("//*[@id='fromcity_chzn']/a"));
        WebElement goingTo = driver.findElement(By.xpath("//*[@id='tocity_chzn']/a"));
    
        leavingFrom.click();
        leavingFrom.sendKeys("Bangalore");
        leavingFrom.sendKeys(Keys.RETURN);
    
        goingTo.click();
        goingTo.sendKeys("Goa");
        goingTo.sendKeys(Keys.RETURN);