seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
5.16k stars 958 forks source link

Cannot perform click on a day on datepicker #2718

Closed manel00 closed 5 months ago

manel00 commented 5 months ago

Hello!

https://www.renfe.com/es/es

image

The problem is, as much as I try, I cannot click on a day for example 27th of April, do you know another way to make it? Thank you as always! something weird goes on in this page hahaha

Code:

def select_dates_main_page(sb, scraped_day, get_next_month):
    two_times = 0
    while two_times != 2:
        list_datatime_elements = None
        list_datatime_elements = sb.find_elements('div.lightpick__days > div')
        for index, item in enumerate(list_datatime_elements):
            date_attribute = item.get_attribute("data-time")
            if date_attribute:
                date_attribute = convert_datetime(int(date_attribute))
                if scraped_day.strftime('%Y-%m-%d') in date_attribute:
                    log.info(date_attribute)
                    list_datatime_elements[index+1].click()
                    sb.sleep(1)
                    break
        two_times += 1
    sb.click('[class="lightpick__apply-action-sub"]', timeout=12)
mdmintz commented 5 months ago

This will click the 27th day on that open calendar with SeleniumBase:

sb.click('div.lightpick__days div:contains("27")')