Date Picker

Could you please help me out with how to handle date picker using Selenium web driver? Like for sample in the site www.yatra.com how can I select a date from the calender ? I tried in many ways but didn’t work. I am finding difficulty to find the element from  the Calender?

KG Train Asked on September 5, 2015 in Selenium WebDriver.
Add Comment
2 Answer(s)

Hope This Helps :-)

try

{
WebDriver driver = new FirefoxDriver();

driver.manage().window().maximize();
driver.get("http://www.yatra.com");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(By.xpath("//input[@name='flight_depart_date']//parent::li//i")).click();
if(driver.findElement(By.xpath("//td[@title[contains(.,' 6 September 2015')]]")).isDisplayed())

{

driver.findElement(By.xpath("//td[@title[contains(.,' 6 September 2015')]]")).click();

}

}

catch(Exception e)

{

e.printStackTrace();

}

Bheem Reddy Supporter Answered on September 6, 2015.
Add Comment

Thanks Bheem Reddy

Really the code which you have given me worked but what is the meaning of “//parent::li//i” which you mentioned in the XPATH of the calender button?

KG Train Answered on September 6, 2015.

this is nothing but traversing to the parent element in the DOM , Similarly we do for following , descending , ascending and ancestor elements accordingly .

on September 6, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.