Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
waitForEvent(event[, optionsOrPredicate])
Caution
This method is a work in progress. It requires async functionality and returning a
Promise
to be useful in scripts. Refer to #447 for details.Consider using the sync methods
Page.waitForNavigation()
andPage.waitForSelector()
instead.
Waits for the event to fire and passes its value into the predicate function. Returns the event data value when the predicate returns true
.
Parameter | Type | Default | Description |
---|---|---|---|
event | string | null | Name of event to wait for. NOTE: Currently this argument is disregarded, and waitForEvent will always wait for 'close' or 'page' events. |
optionsOrPredicate | function|object | null | Optional. If it’s a function, the 'page' event data will be passed to it and it must return true to continue. |
optionsOrPredicate.predicate | function | null | Function that will be called when the 'page' event is emitted. The event data will be passed to it and it must return true to continue. |
optionsOrPredicate.timeout | number | 30000 | Maximum time to wait in milliseconds. Pass 0 to disable timeout. |
Returns
Type | Description |
---|---|
object | Page object |