Rayrun
← Back to Discord Forum

Button click does not trigger data refresh

Hi everyone, I am very new to Playwright and Python. I am trying to scrape data from the website below.

I am able to change the month and year selection (to Jan 2020 then Feb 2020 for example), but clicking the Done button just hides the date picker without triggering a data refresh. Appreciate some guidance as I have been stuck on this problem for days. Thanks in advance.

from playwright.sync_api import Playwright, sync_playwright from bs4 import BeautifulSoup import time

url = 'https://www.bdo.com.ph/personal/navpu-history/bdo-equity-fund?code=BDO-EQUITY'

def run(playwright: Playwright) -> None: with playwright.chromium.launch(headless=False) as browser: page = browser.new_page() page.goto(url)

months = ['0', '1']
    year = '2020'

    for month in months:
        page.click('#navpu-date')
        page.wait_for_selector('.ui-datepicker-month')
        page.select_option('.ui-datepicker-month', month)
        # page.evaluate("document.querySelector('.ui-datepicker-month').onchange()")
        # page.evaluate("document.querySelector('.ui-datepicker-month').onclick()")
        # page.dispatch_event('.ui-datepicker-month', 'change')
        # page.dispatch_event('.ui-datepicker-month', 'click')
        page.select_option('.ui-datepicker-year', year)
        # page.dispatch_event('.ui-datepicker-year', 'change')
        # page.dispatch_event('.ui-datepicker-year', 'click')
        # page.evaluate("document.querySelector('.ui-datepicker-year').onchange()")
        # page.evaluate("document.querySelector('.ui-datepicker-year').onclick()")
        time.sleep(10)
        page.click('.ui-datepicker-close')
        # page.evaluate("document.querySelector('.ui-datepicker-close').click()")
        # page.dispatch_event('.ui-datepicker-close', 'click')
        time.sleep(10)

with sync_playwright() as playwright: run(playwright)

This thread is trying to answer question "How to trigger data refresh after clicking the 'Done' button using Playwright and Python?"

3 replies
tphillips8117

Calling click() on page is deprecated, you need to use a locator and call click on that locator

datepicker.click()```
tphillips8117

Also don't use wait_for_selector, it's deprecated. Use locators instead: https://playwright.dev/python/docs/api/class-page#page-wait-for-selector

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.