0
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Make_my_trip {

    public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "F:\\Selenium\\chromedriver.exe");
WebDriver driver = new ChromeDriver();

driver.get("https://www.makemytrip.com/");
driver.manage().window().maximize();

    driver.findElement(By.xpath("//input[@mt-id ='departDate']")).click();
    driver.findElement(By.cssSelector("[class='ui-datepicker-calendar'] > tbody > tr:nth-child(5) > td:nth-child(3) > a"))
                .click();

Error :Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element ... is not clickable at point (352, 560). Other element would receive the click:

Palak Soni
  • 53
  • 1
  • 11

1 Answers1

0

Looks like its a readonly field.I have tried JavaScript Executor to set the value. Please try the below code see if this help.

JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("document.getElementById('hp-widget__depart').value='2 Mar,Fri';");

OR

WebElement elementdept=driver.findElement(By.xpath("//input[@mt-id='departDate']"));
elementdept.click();        
driver.findElement(By.cssSelector("a.ui-state-active")).click();
KunduK
  • 32,888
  • 5
  • 17
  • 41
  • I don't want to give **Hardcoded** value. whatever will be the current date it should be select automatically. – Palak Soni Feb 28 '19 at 14:28
  • @PalakSoni, I have updated my answer.Try the second one.See if it helps you. – KunduK Feb 28 '19 at 17:02
  • Try the options 2. – KunduK Feb 28 '19 at 17:03
  • Yes , Now it is working thanks . I write below code : `driver.findElement(By.xpath("//input[@id ='hp-widget__depart']")).click();` `driver.findElement(By.cssSelector(".ui-state-default.ui-state-highlight.ui-state-active.ui-state-hover")).click();` – Palak Soni Feb 28 '19 at 19:10
  • @PalakSoni , when you are using `cssSelector` not necessary to use all.you can just use one of the class value.Happy to help you. – KunduK Feb 28 '19 at 19:46