How can I select the date within a Slick Slickslider date control for a bot?

18 views Asked by At

I am using Python to create a bot to automatically schedule a court time for a court scheduler app. The software only allows you to book 3 days out starting at 8:00am so I plan to automate this task to go in and book a court for me exactly at 8:00:01 when the system opens.

The app is behind a login at a private web site - (https://www.pwyc.com/Courts/CourtScheduler). I am using Selenium and can get logged into the site, and even select the court scheduler app.

Inspecting the web page (see below), it looks like the "date ng-binding" is the correct element that sets the date and I am using in my date_xpath which is causing errors.

I am new at coding and especially python website bots. Can someone please help put me on the right path to debugging this?

My code:

`from selenium.webdriver.chrome.service import Service  # Import Service class for Selenium 4 or later
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import datetime

current_date = datetime.date.today()  # Get current date
target_date = current_date + datetime.timedelta(days=3)  # Add 3 days
target_date_text = target_date.strftime("%b %d")  # Format as "Dec 23" # constructs the path for the date 3 days out
date_xpath = f"//div[@class='date ng-binding' and text()='{target_date_text}']"

# finds and clicks this date element to select the date 3 days out
date_element = driver.find_element(By.XPATH, date_xpath)  # Use the dynamic XPath
date_element.click()

wait = WebDriverWait(driver, 20)  # Wait up to 20 seconds
date_element = wait.until(EC.element_to_be_clickable((By.XPATH, date_xpath)))
date_element.click()

wait.until(EC.angularHasFinished())  # Wait for AngularJS to finish`

Excerpt from the slick slider code using web inspect:

`<div class="items slick-initialized slick-slider">
    <div aria-live="polite" class="slick-list draggable"><div class="slick-track" style="opacity: 1; width: 39162px; transform: translate3d(0px, 0px, 0px);" role="listbox"><div class="item info slick-slide" ng-init="setDate(0, 0)" ng-click="setDate(0, 0)" data-slick-index="0" aria-hidden="true" style="width: 107px;" tabindex="-1" role="option" aria-describedby="slick-slide00">Info</div><div class="item ng-scope slick-slide slick-current slick-active date-selected" data-index="$index+1" ng-repeat="date in datesObj" ng-click="setDate($index+1, date)" data-slick-index="1" aria-hidden="false" style="width: 107px;" tabindex="-1" role="option" aria-describedby="slick-slide01">
      <div class="day ng-binding">Today, Thu</div>
      <div class="date ng-binding">Dec 21</div>
    </div><div class="item ng-scope slick-slide slick-active" data-index="$index+1" ng-repeat="date in datesObj" ng-click="setDate($index+1, date)" data-slick-index="2" aria-hidden="false" style="width: 107px;" tabindex="-1" role="option" aria-describedby="slick-slide02">
      <div class="day ng-binding">Fri</div>
      <div class="date ng-binding">Dec 22</div>`

<

<note: this then repeats for each date>>>

I tried :

`current_date = datetime.date.today()  # Get current date
target_date = current_date + datetime.timedelta(days=3)  # Add 3 days
target_date_text = target_date.strftime("%b %d")  # Format as "Dec 23" # constructs the path for the date 3 days out
date_xpath = f"//div[@class='date ng-binding' and text()='{target_date_text}']"

# finds and clicks this date element to select the date 3 days out
date_element = driver.find_element(By.XPATH, date_xpath)  # Use the dynamic XPath
date_element.click()
`

AND I expected that this would click/select the date 3 days out from today's date (e.g. December 26th).

What actually happens is I receive these errors in python: C:\Users\matt0\AppData\Local\Programs\Python\Python39\python.exe C:\Users\matt0\PycharmProjects\Courtbot\main.py Traceback (most recent call last): File "C:\Users\matt0\PycharmProjects\Courtbot\main.py", line 47, in <module> date_element = wait.until(EC.element_to_be_clickable((By.XPATH, date_xpath))) File "C:\Users\matt0\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\support\wait.py", line 105, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: Stacktrace: GetHandleVerifier [0x00007FF7CA872142+3514994] (No symbol) [0x00007FF7CA490CE2] (No symbol) [0x00007FF7CA3376AA] (No symbol) [0x00007FF7CA381860] (No symbol) [0x00007FF7CA38197C] (No symbol) [0x00007FF7CA3C4EE7] ...

0

There are 0 answers