click datepicker using Selenium + Python + ChromeDriver

1,064 views
Skip to first unread message

Shay Ben David

unread,
May 27, 2018, 9:15:51 AM5/27/18
to Selenium Users
Hi all,
I'm a newbie in coding,
i'm trying to find a way to click a calendar using python with selenium + chrome web driver, but cannot find the 'clickable' element.

URL: https://www.sanparks.org/bookings (requires registration/login)
i've attached the website's html and a snapshot of the calendar element inspection in chrome.

Appreciate you help!
Thanks
test1.PNG
sanparks HTML.txt

Shiva Prasad Adirala

unread,
May 27, 2018, 12:54:58 PM5/27/18
to Selenium Users
Hi,
I have gone through website. Input tag has read-only attributes. Following are the steps need to be performed to select date

1. Click on date picker input tag
    webDriver.findElement(By.cssSelector(".datePickerContainer input")).click();

2. Select next to get specific month
    webDriver.findElement(By.xpath("//span[text()='Next']")).click();

3. Select date
    webDriver.findElement(By.xpath("(//a[text()='14'])[3]")).click();

Snippet:

                webDriver.findElement(By.cssSelector(".datePickerContainer input")).click();
// Click on next to get August month
webDriver.findElement(By.xpath("//span[text()='Next']")).click();
// Xpath: (//a[text()='DATE'])[MONTH_1/2/3]
// Explanation: I want to select 14th date from August //a[text()='14']
// There are only 3 months active in window. so August is the 3rd month [3]
webDriver.findElement(By.xpath("(//a[text()='14'])[3]")).click();

For better code - please go through datepicker in selenium Hope this help you to select date.
Thanks,
Shiva

Shay Ben David

unread,
May 27, 2018, 3:59:29 PM5/27/18
to Selenium Users
Dude you definitely nailed it!
Works perfect, i've also managed to get the value of available rooms in specific dates and call another py for SMTP alert.
Thanks alot!

בתאריך יום ראשון, 27 במאי 2018 בשעה 19:54:58 UTC+3, מאת Shiva Prasad Adirala:
Reply all
Reply to author
Forward
0 new messages