Version: 1.13.0
Events
Playwright allows listening to various types of events happening in the web page, such as network requests, creation of child pages, dedicated workers etc. There are several ways to subscribe to such events:
#
Waiting for eventMost of the time, scripts will need to wait for a particular event to happen. Below are some of the typical event awaiting patterns.
Wait for a request with the specified url:
- Sync
- Async
Wait for popup window:
- Sync
- Async
#
Adding/removing event listenerSometimes, events happen in random time and instead of waiting for them, they need to be handled. Playwright supports traditional language mechanisms for subscribing and unsubscribing from the events:
- Sync
- Async
#
Adding one-off listenersIf certain event needs to be handled once, there is a convenience API for that:
- Sync
- Async