Skip to content

feat(web): add browser.consoleMessages() and browser.pageErrors() - #2110

Closed
satya164 wants to merge 5 commits into
mainfrom
t3/browser-console-errors
Closed

satya164 wants to merge 5 commits into
mainfrom
t3/browser-console-errors

Conversation

@satya164

@satya164 satya164 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

  • browser.consoleMessages() and browser.pageErrors() on @e2e-dev/web return the active tab's console messages, uncaught errors, and unhandled rejections since the tab opened. Before this, you had to add an init script that wrapped console.error and listened for error and unhandledrejection, then read the results back with evaluate.
  • Both read Playwright's per-page lists with { filter: 'all' } (packages/web/src/browser.ts). Playwright's default, 'since-navigation', would drop entries at each navigation. Playwright keeps up to 200 of the latest entries per list.
  • After app.restart(), the lists only have the new page's entries, because a restart closes the tab and opens a new page.
  • A persistent browser (connect.reconnectEndpoint, or a provider in attempt scope) reuses its own first tab. Chrome replays that tab's earlier console output and errors to a new CDP client, so the engine now clears both lists after it moves that tab to about:blank (packages/web/src/attempt-session.ts).
  • The return values only go to the test. The steps are recorded as browser.consoleMessages and browser.pageErrors without a label, and this change doesn't write the text to any report or artifact. Console output still shows up in the app log, as before.
test('the checkout page logs no errors', async ({ app, browser }) => {
  await app.open('/checkout');
  const errors = (await browser.consoleMessages()).filter((message) => message.type === 'error');
  expect(errors).toEqual([]);
  expect(await browser.pageErrors()).toEqual([]);
});
export interface WebConsoleMessage {
  readonly type: ReturnType<ConsoleMessage['type']>; // Playwright's union: 'log', 'warning', 'error', ...
  readonly text: string;
}

export interface WebPageError {
  readonly message: string;
  readonly stack: string; // empty for a thrown value that is not an Error
}

Error codes the new methods can throw:

Code When
APP_NOT_OPEN No page is open yet.
ACTION_FAILED The call ran past actionTimeout.
ENGINE_FAILURE The browser connection was lost.

There are no new error codes. docs/reference/errors.mdx already lists all three.

Docs: docs/reference/web.mdx (two entries, the summary table, the Browser block, the type exports), the Playwright migration guide (a mapping row, and the workaround row now covers only page.clock), and skills/e2e/references/writing-tests.md.

Verified

Ran it locally: yes, on Chromium.

Firefox wasn't verified. Playwright's Firefox 159 (revision 1572) exits at launch on this Mac with Could not find profile folder. It fails the same way when started directly (firefox -headless -profile <dir> --screenshot) and from a fresh install. No CI job runs Firefox.

  • Testbed, the built CLI, e2e run tests/browser.e2e.ts. The new test logs with console.error, leaves a rejection unhandled, and throws from a timer. All three are read back, and the lists are empty after app.restart():
 ✓ target "web" command at http://127.0.0.1:4271/ ready 98ms
   ✓ |web| tests/browser.e2e.ts > browser fixture > navigation verbs and the URL and title matchers 430ms
   ✓ |web| tests/browser.e2e.ts > browser fixture > reload runs the page again 144ms
   ✓ |web| tests/browser.e2e.ts > browser fixture > an init script runs before the page reads it, from the next load on 145ms
   ✓ |web| tests/browser.e2e.ts > browser fixture > the viewport size is what the page measures 135ms
   ✓ |web| tests/browser.e2e.ts > browser fixture > cookies set from the test reach the page and read back 176ms
   ✓ |web| tests/browser.e2e.ts > browser fixture > console messages and page errors read back until a restart 198ms
   ✓ |web| tests/browser.e2e.ts > emulated media reaches the page's own @media rules, from the first paint on 257ms
      Tests  7 passed (7)
  • A throwaway testbed test printed the values across a navigation and a restart:
{
  "messages": [{ "type": "log", "text": "ready" }, { "type": "error", "text": "broken 42" }],
  "errors": [{ "message": "thrown", "stack": "Error: thrown" }, { "message": "rejected", "stack": "Error: rejected" }]
}
{"afterRestart":{"messages":[],"errors":[]}}
  • Report check: .e2e/report.json only has the step names browser.consoleMessages and browser.pageErrors. The broken 42 and error lines in it come from the existing app log.
  • Persistent first tab, packages/web/tests/integration/console-messages.test.ts. A remote Chrome's tab logs and throws, then the engine attaches with reconnectEndpoint:
without the clear calls this branch
pageErrors() returns thrown and rejected from before the attempt []

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.

🤖 Generated with Claude Code

satya164 and others added 4 commits November 23, 2026 16:10
Read the active tab's console messages and its uncaught errors and
unhandled rejections since it opened, from Playwright's own per-page
lists, so a test no longer wraps console.error in an init script.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r review findings

Chrome replays a tab's earlier console messages and errors to a new CDP
client, so the persistent browser's own first tab started the attempt
with output from before it. Type console messages with Playwright's type
union, cover non-Error values and app.restart() on the testbed, and say
what the lists hold more exactly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added e2e team Opened by the e2e team size:L Up to 499 changed lines, not counting tests, fixtures, translated docs, or the lockfile labels Nov 23, 2026
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e web: 95 passed

All 95 tests in 43 files
Test Time
🟢 tests/aria-hidden-flow.e2e.ts · 2 passed 763ms
🟢 aria hidden flow › picks the Pro plan by its visible text and confirms it 565ms
🟢 aria hidden flow › another plan shows the error and keeps the picker open 198ms
🟢 tests/async-states.e2e.ts · 2 passed 7.0s
🟢 async states › reads the code off the transient toast and verifies it once the button enables 2.2s
🟢 async states › a wrong code is rejected after the toast has gone 4.7s
🟢 tests/canvas-only.e2e.ts · 2 passed 351ms
🟢 canvas only › taps square, circle, then diamond at their pixel coordinates 186ms
🟢 canvas only › a shape out of order paints the error and resets progress 165ms
🟢 tests/canvas-whiteboard.e2e.ts · 2 passed 473ms
🟢 canvas whiteboard › drags both shapes into their slots and saves 297ms
🟢 canvas whiteboard › bounces a shape off the wrong slot and refuses to save early 176ms
🟢 tests/cart-totals.e2e.ts · 2 passed 484ms
🟢 cart totals › increasing a quantity updates the line total but the order summary stays stale (planted bug) 275ms
🟢 cart totals › a quantity never drops below one 209ms
🟢 tests/checkout-review.e2e.ts · 1 passed 199ms
🟢 shows a raw greeting token and an undefined delivery date (planted bug), yet places the order 199ms
🟢 tests/context-menu-trap.e2e.ts · 2 passed 740ms
🟢 context menu trap › right-click opens nothing; the row menu renames the file 382ms
🟢 context menu trap › the decoy menu items refuse and keep the file 358ms
🟢 tests/control-inventory.e2e.ts · 8 passed 3.8s
🟢 control inventory › check sets the checkbox and the radio without flipping a set one 283ms
🟢 control inventory › check picks a radio the pick replaces with its summary 214ms
🟢 control inventory › a long press and a double click are told apart from a tap 1.1s
🟢 control inventory › the file menu opens on right-click only and Rename renames the file 319ms
🟢 control inventory › setInputFiles attaches files named from the project root 178ms
🟢 control inventory › the details view is left through the browser history 206ms
🟢 control inventory › scrollIntoView brings the footnote into view 214ms
🟢 control inventory › every exercise done shows the success message 1.3s
🟢 tests/css-content-ui.e2e.ts · 2 passed 448ms
🟢 css content ui › the tile labelled Ship it advances and confirming ships 248ms
🟢 css content ui › a wrong tile shows the CSS-rendered error and keeps the picker 200ms
🟢 tests/date-picker.e2e.ts · 2 passed 740ms
🟢 date picker › navigates three months ahead and books the required date 408ms
🟢 date picker › confirming without the exact date shows the error 332ms
🟢 tests/debounced-search.e2e.ts · 2 passed 2.8s
🟢 debounced search › a decoy one character off is refused 1.4s
🟢 debounced search › picking the exact item adds it to the cart 1.4s
🟢 tests/deferred-dialog.e2e.ts · 1 passed 1.0s
🟢 one submit opens one confirm, even when double-clicked 1.0s
🟢 tests/div-soup.e2e.ts · 2 passed 694ms
🟢 div soup › a wrong code is rejected 329ms
🟢 div soup › the right code grants access after the delete tile fixes a typo 365ms
🟢 tests/drag-and-drop.e2e.ts · 2 passed 697ms
🟢 drag and drop › an out-of-order item resets the dropzone 350ms
🟢 drag and drop › dropping Banana then Cherry passes 347ms
🟢 tests/file-round-trip.e2e.ts · 2 passed 414ms
🟢 file round trip › downloads the issued voucher and verifies the same file uploaded back 203ms
🟢 file round trip › rejects a file that is not the voucher, then accepts the issued one 211ms
🟢 tests/filter-deep-link.e2e.ts · 2 passed 291ms
🟢 filter deep link › filtering writes the query to the URL 163ms
🟢 filter deep link › opening a shared link restores the filter 128ms
🟢 tests/gift-card-purchase.e2e.ts · 3 passed 690ms
🟢 gift card purchase › refuses to buy without an amount 206ms
🟢 gift card purchase › refuses a recipient without an at sign 249ms
🟢 gift card purchase › sends the gift card 235ms
🟢 tests/hover-menu.e2e.ts · 2 passed 525ms
🟢 hover menu › a decoy leaf is refused 262ms
🟢 hover menu › hovering Account, then Billing, reaches Redeem voucher 263ms
🟢 tests/iframe-form.e2e.ts · 2 passed 560ms
🟢 iframe form › a wrong code is refused by the host page 280ms
🟢 iframe form › the code read from one frame applies through the other 280ms
🟢 tests/image-only-ui.e2e.ts · 3 passed 503ms
🟢 image only ui › the icons have no names, so the bare svg locator is ambiguous 106ms
🟢 image only ui › a wrong icon shows the error image and keeps the icons 184ms
🟢 image only ui › tapping the star, then the heart, verifies the icons 213ms
🟢 tests/infinite-scroll.e2e.ts · 1 passed 2.7s
🟢 scrolls the feed until the Golden Ticket loads, then claims it 2.7s
🟢 tests/kanban-board.e2e.ts · 3 passed 751ms
🟢 kanban board › pointer drags move both cards into the goal layout 385ms
🟢 kanban board › a swipe along a path drags a card as well 149ms
🟢 kanban board › a plain tap moves nothing and the untouched board is rejected 217ms
🟢 tests/login-form.e2e.ts · 4 passed 800ms
🟢 login form › rejects a malformed email 184ms
🟢 login form › rejects a short password 182ms
🟢 login form › rejects an unknown account 186ms
🟢 login form › signs in and logs out 248ms
🟢 tests/lying-labels.e2e.ts · 4 passed 693ms
🟢 lying labels › the button whose accessible name says Pay now is the wrong one 148ms
🟢 lying labels › a text match for Pay now catches the decoy phrase too 114ms
🟢 lying labels › the field whose accessible name says Amount is the wrong one 215ms
🟢 lying labels › visible text drives the payment through 216ms
🟢 tests/native-dialogs.e2e.ts · 3 passed 469ms
🟢 native dialogs › answers the confirm, prompt, and alert chain 171ms
🟢 native dialogs › dismissing the confirm cancels the order 166ms
🟢 native dialogs › a wrong gift code is rejected 132ms
🟢 tests/new-tab-flow.e2e.ts · 2 passed 430ms
🟢 new tab flow › reads the code in the tab the app opens and enters it back in the original tab 245ms
🟢 new tab flow › a tap that opens a tab leaves the screen on the original tab, and activate shows the new one 185ms
🟢 tests/newsletter-signup.e2e.ts · 1 passed 2.2s
🟢 subscribe renders no feedback and logs a TypeError (planted bug) 2.2s
🟢 tests/onboarding-wizard.e2e.ts · 5 passed 6.0s
🟢 onboarding wizard › back keeps what was typed and the brief comes back with it 330ms
🟢 onboarding wizard › the address step takes the brief through its bare-div dropdown 378ms
🟢 onboarding wizard › the profile step steers the calendar three decades back 1.6s
🟢 onboarding wizard › the preferences step flips the toggles the brief names and leaves the trap off 1.8s
🟢 onboarding wizard › the review step repeats the brief and finishes with the PIN 1.9s
🟢 tests/order-history.e2e.ts · 2 passed 1.6s
🟢 order history › overview and settings render their panels 281ms
🟢 order history › the orders tab never leaves its loading state (planted bug) 1.3s
🟢 tests/otp-auto-advance.e2e.ts · 3 passed 1.5s
🟢 otp auto-advance › focus advances with each digit and the full code verifies 487ms
🟢 otp auto-advance › backspace on an empty box clears and refocuses the previous one 190ms
🟢 otp auto-advance › a wrong code clears every box and starts over 831ms
🟢 tests/overlay-trap.e2e.ts · 1 passed 770ms
🟢 continues only after the banner and the overlay are gone 770ms
🟢 tests/playbook-cleanup.e2e.ts · 2 passed 611ms
🟢 playbook cleanup › deleting the draft removes it from an exact-name search 301ms
🟢 playbook cleanup › cancelling the dialog keeps the draft searchable 310ms
🟢 tests/price-sorting.e2e.ts · 3 passed 514ms
🟢 price sorting › opens in the featured order with sale prices struck through 142ms
🟢 price sorting › low to high sorts by the original price, not the paid one (planted bug) 183ms
🟢 price sorting › high to low is the same wrong order reversed (planted bug) 189ms
🟢 tests/product-reviews.e2e.ts · 1 passed 1.2s
🟢 the running-shoe page lists coffee-grinder reviews (planted bug) 1.2s
🟢 tests/promo-storefront.e2e.ts · 1 passed 1.4s
🟢 buys a deal once the promo chrome is out of the way 1.4s
🟢 tests/rich-text-editor.e2e.ts · 2 passed 611ms
🟢 rich text editor › bolding exactly the required word passes the check 311ms
🟢 rich text editor › bold that spills into the previous word fails the check 300ms
🟢 tests/saved-addresses.e2e.ts · 3 passed 732ms
🟢 saved addresses › adds an address and clears the form 244ms
🟢 saved addresses › ignores an add with an empty field 229ms
🟢 saved addresses › delete shows its toast but keeps the address, on retry too (planted bug) 259ms
🟢 tests/shadow-dom-form.e2e.ts · 2 passed 464ms
🟢 shadow DOM form › rejects a wrong access code 233ms
🟢 shadow DOM form › grants access with the code from the hint inside the root 231ms
🟢 tests/smoke.e2e.ts · 1 passed 297ms
🟢 home lists the scenarios and opens one 297ms
🟢 tests/stale-dom.e2e.ts · 1 passed 2.1s
🟢 taps the moving target three times across rebuilds of the list 2.1s
🟢 tests/sticky-chrome.e2e.ts · 1 passed 254ms
🟢 accepts the terms once the button clears the sticky footer 254ms
🟢 tests/virtualized-table.e2e.ts · 1 passed 14.9s
🟢 scrolls the windowed table to the Golden Row and claims it 14.9s
🟢 tests/wishlist.e2e.ts · 2 passed 1.5s
🟢 wishlist › saving toggles the button and the tab badge 226ms
🟢 wishlist › the wishlist tab renders the empty state despite the badge count (planted bug) 1.2s

Tested by e2e 0.24.0 · 1m 6s · web · run artifacts

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e web agent: 34 passed

35 agent steps · 26 replayed from cache · 27 model calls · 147.9k tokens (94% cached) · $0.0061

All 34 tests in 5 files
Test Agent Time
🟢 tests-agent/control-inventory.e2e.ts · 7 passed 7 steps 7.7s
🟢 control inventory › check sets the checkbox and the radio 1 step 758ms
🟢 control inventory › check picks a radio the pick replaces with its summary 1 step 318ms
🟢 control inventory › a long press and a double click are chosen over a plain tap 1 step 964ms
🟢 control inventory › a right-click opens the file menu and Rename renames the file 1 step 2.6s
🟢 control inventory › upload attaches the named project files 1 step 2.4s
🟢 control inventory › back returns from the details view to the inventory 1 step 294ms
🟢 control inventory › scroll_to brings the footnote into view 1 step 390ms
🟢 tests-agent/login-form.e2e.ts · 1 passed 1 step 382ms
🟢 act signs in with the benchmark account 1 step 382ms
🟢 tests-agent/planted-bugs.e2e.ts · 3 passed 4 steps · 8 calls 11.4s
🟢 cart totals: a judgment catches the stale order summary 2 steps · 4 calls 5.4s
🟢 checkout review: a judgment catches the broken copy 1 step · 1 call 2.1s
🟢 wishlist: a judgment catches the lost saved items 1 step · 3 calls 3.9s
🟢 tests-agent/scenarios.e2e.ts · 22 passed 22 steps · 19 calls 1m 22s
🟢 act completes shadow-dom-form 1 step · 4 calls 4.6s
🟢 act completes lying-labels 1 step · 4 calls 6.5s
🟢 act completes iframe-form 1 step · 3 calls 4.5s
🟢 act completes infinite-scroll 1 step 3.4s
🟢 act completes virtualized-table 1 step 21.7s
🟢 act completes overlay-trap 1 step 922ms
🟢 act completes sticky-chrome 1 step 930ms
🟢 act completes async-states 1 step · 3 calls 6.8s
🟢 act completes debounced-search 1 step 2.3s
🟢 act completes hover-menu 1 step 529ms
🟢 act completes drag-and-drop 1 step 481ms
🟢 act completes kanban-board 1 step 673ms
🟢 act completes context-menu-trap 1 step 2.7s
🟢 act completes stale-dom 1 step 531ms
🟢 act completes otp-auto-advance 1 step 765ms
🟢 act completes date-picker 1 step 896ms
🟢 act completes rich-text-editor 1 step 10.1s
🟢 act completes playbook-cleanup 1 step 594ms
🟢 act completes promo-storefront 1 step 2.3s
🟢 act completes new-tab-flow 1 step · 5 calls 8.3s
🟢 act completes gift-card-purchase 1 step 2.4s
🟢 act filters the list and the URL carries the filter 1 step 227ms
🟢 tests-agent/unique-cache.e2e.ts · 1 passed 1 step 310ms
🟢 act adds an address with a run-unique label 1 step 310ms

Tested by e2e 0.24.0 · 1m 43s · web · run artifacts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@satya164 satya164 closed this Nov 23, 2026
@satya164
satya164 deleted the t3/browser-console-errors branch November 23, 2026 15:19
@satya164

Copy link
Copy Markdown
Collaborator Author

Moved to #2113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e team Opened by the e2e team size:L Up to 499 changed lines, not counting tests, fixtures, translated docs, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant