Console and page events
Console output, dialogs, requests, responses, failed requests, popups. Listen to the signals exposed by the PHP client and assert on what matters.
- Console Fail the test on a console error
- Dialogs A confirm box no longer blocks the run
- Popups New windows arrive as objects, not accidents
Fail the test on a console error
Collect console messages while the scenario runs and assert none of them are unexpected errors. Browser-side failures written to the console stop shipping unnoticed.
Page and browser events →$page->on('console', function ($message) use (&$errors) {
if ('error' === $message->type()) {
$errors[] = $message->text();
}
});A confirm box no longer blocks the run
Alerts, confirms, prompts, and beforeunload are handled by a listener that accepts or dismisses. Unhandled, they are auto-dismissed rather than hanging the page.
Handle a dialog →New windows arrive as objects, not accidents
A window opened by the page surfaces as a Page you can drive with the same locators and assertions as its opener.
Handle a popup window →Move from the tour to working code.
Choose the explanation, recipe, or runnable example that matches what you need next.