click datepicker using Selenium + Python + ChromeDriver

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

click datepicker using Selenium + Python + ChromeDriver

Shay Ben David
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

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6887f20a-b457-4b73-ba7e-e531a2e8ca22%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

test1.PNG (1M) Download Attachment
sanparks HTML.txt (170K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: click datepicker using Selenium + Python + ChromeDriver

Shiva Prasad Adirala
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


On Sunday, May 27, 2018 at 6:45:51 PM UTC+5:30, Shay Ben David wrote:
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: <a href="https://www.sanparks.org/bookings" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.sanparks.org%2Fbookings\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHF34JEX5uk-JhJFZ6fMb2LdVhMxw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.sanparks.org%2Fbookings\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHF34JEX5uk-JhJFZ6fMb2LdVhMxw&#39;;return true;">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

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/16c16bdc-983f-45f9-998c-6fdac76b1924%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: click datepicker using Selenium + Python + ChromeDriver

Shay Ben David
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:
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


On Sunday, May 27, 2018 at 6:45:51 PM UTC+5:30, Shay Ben David wrote:
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: <a href="https://www.sanparks.org/bookings" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.sanparks.org%2Fbookings\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHF34JEX5uk-JhJFZ6fMb2LdVhMxw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.sanparks.org%2Fbookings\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHF34JEX5uk-JhJFZ6fMb2LdVhMxw&#39;;return true;">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

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/cd8755b9-1e2c-4599-b55c-201255762ace%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.