0

I want to select return date from the calendar on a booking website. it select the first "From:" date but is unable to select the Return date i have also tried using wrapping the xpath.

 public static void main(String[] args) throws InterruptedException 
{
    System.setProperty("webdriver.gecko.driver","C:\\geckodriver-v0.17.0-win64\\geckodriver.exe");
    WebDriver driver = new FirefoxDriver();
    driver.get("https://www.makemytrip.com/");
    Thread.sleep(3000L);
    driver.findElement(By.xpath(".//*[@id='hp-widget__sfrom']")).click();
    driver.findElement(By.xpath(".//*[@id='hp-widget__sfrom']")).sendKeys("GOI");
    driver.findElement(By.xpath(".//*[@id='hp-widget__sfrom']")).sendKeys(Keys.TAB);
    Thread.sleep(3000L);
    driver.findElement(By.xpath(".//*[@id='hp-widget__sTo']")).sendKeys("AMD");
    driver.findElement(By.xpath(".//*[@id='hp-widget__sTo']")).sendKeys(Keys.TAB);
    driver.findElement(By.xpath(".//*[@id='hp-widget__depart']")).click();
    driver.findElement(By.xpath(".//*[@data-month='0'][5]//a[text()='26']")).click();
    Thread.sleep(3000L);
    driver.findElement(By.xpath(".//*[@id='hp-widget__return']")).click();
    driver.findElement(By.xpath("(.//*[@data-month='0']//a[text()='29'])[2]")).click();
}
}

I want to select the REtun date as well

Exception in thread "main" org.openqa.selenium.ElementNotInteractableException:

Gal Shaboodi
  • 744
  • 1
  • 7
  • 25
Dhrumil Pathak
  • 101
  • 3
  • 11
  • Please indent the code accordingly – Mahmud Riad Dec 04 '17 at 14:24
  • Which line returns the exception? – Bill Hileman Dec 04 '17 at 14:40
  • It's likely that the return date widget is not ready to interact, even with a 3-second sleep. You probably should use a wait for it to be clickable. Underlying code may be working in the background to set the minimum date value based upon the departure date, I date recommending extending the sleep as as try to avoid sleeps entirely, but that would be one way to try. – Bill Hileman Dec 04 '17 at 14:46
  • This may Answer your Question https://stackoverflow.com/questions/44690971/selenium-webdriver-throws-exception-in-thread-main-org-openqa-selenium-elemen/44691041#44691041 – undetected Selenium Dec 04 '17 at 14:56
  • While it could be that the **return date widget** is not yet **ready to interact**, I think it's more likely that the `By.xpath(".//*[@id='hp-widget__return']")` is just not intractable. Try inspecting in chrome dev tools. When I've seen this in the past it's usually because the element you want to click is a **parent, child, or sibling** of the element you thought you wanted to click. – mrfreester Dec 04 '17 at 18:23
  • Thanks every one for the help it solved my problem. – Dhrumil Pathak Dec 05 '17 at 04:40

0 Answers0