I am trying to select a "Depart date" as of 31st october 2018 from the calender https://spicejet.com/ But I am getting error "unknown error: Element is not clickable at point (832, 242). Other element would receive the click: ..." Please help me out. Here is my code getting such exception:
public class bookflight extends Thread {
UtilityMethods utilObj= new UtilityMethods();
@Test
public void SighnUp() throws IOException
{
utilObj.getdriver().get("https://spicejet.com");
utilObj.getdriver().manage().window().maximize();
utilObj.getdriver().findElement(By.id("ctl00_mainContent_ddl_originStation1_CTXT")).click();
utilObj.getdriver().findElement(By.xpath("//a[contains(text(),'Guwahati (GAU)')]")).click();
utilObj.getdriver().findElement(By.xpath("//a[contains(text(),'Goa (GOI)')]")).click();
utilObj.getdriver().findElement(By.className("ui-datepicker-trigger")).click();
utilObj.getdriver().findElement(By.xpath("//div[@class='ui-datepicker-group ui-datepicker-group-first'])/parent:://table[@class='ui-datepicker-calendar']following-sibling::./a/contains(text(),'31')")).click();
}
}
There is lots of different factors which results into this exception, i like to suggest you to try putting some wait.
then try clicking element,
I hope below code is helpful and handle departure and return date
To select From (e.g. Guwahati(GAU)), To (e.g. Goa(GOI)) destination and DEPART DATE as 31/10 within the url
https://spicejet.com/
you need to induce WebDriverWait for the desired element to be clickable and you can use the following solution:Code Block:
Browser Snapshot:
Updated answer to click next date.
You can modify the above
XPATH
to select date based onYEAR/MONTH/DATE
. for moreXPath creation go-through my answers
.When you enter
FROM
andTO
data, thenDEPART DATE
field get auto selected. So, just you need to select the first data using javascript.sample test program.
NOTE: If you are selecting
DEPART DATE
which got auto selected then selenium throws exceptionYou can click on element by Action class, based on Exception type: