Closed jean closed 4 years ago
Thanks for filing this! We modified the way that events are handled and neglected to update the example scripts. In the version of the script that you ran, the event listener starts after navigation begins, which causes a race condition. If the page load fires before the event listener starts (e.g. if the page is served from local cache) then the listener will hang forever.
The new approach is to register the event listener first using an async with
block, then to perform the action that will trigger that event:
async with session.wait_for(page.LoadEventFired):
await session.execute(page.navigate(target_url))
I have updated both example scripts accordingly and retested to make sure they work.
I was trying the
get_title.py
example, but it fails with aTypeError
: