Repository navigation
Conversation
2 of 5 tasks
Contributor
🟢 e2e web agent: 34 passed36 agent steps · 26 replayed from cache · 26 model calls · 135.3k tokens (93% cached) · $0.0060 All 34 tests in 5 files
Tested by e2e 0.24.0 · 1m 39s · web · run artifacts |
Contributor
🟢 e2e web: 95 passedAll 95 tests in 43 files
Tested by e2e 0.24.0 · 1m 8s · web · run artifacts |
satya164
force-pushed
the
@satya164/browser-console-errors
branch
2 times, most recently
from
November 24, 2026 10:24
2f071f6 to
ae853b6
Compare
satya164
force-pushed
the
@satya164/browser-console-errors
branch
from
November 25, 2026 10:27
d73c252 to
afa9368
Compare
satya164
force-pushed
the
@satya164/browser-console-errors
branch
from
November 25, 2026 12:35
17d3df7 to
a30f448
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
browser.consoleMessages()andbrowser.pageErrors()on@e2e-dev/webreturn the console messages, uncaught errors, and unhandled promise rejections in the active tab since it opened.Each message has
{ type, text }, and each error has{ name, message, stack }. A call can fail withAPP_NOT_OPEN(no page is open yet),ACTION_FAILED(timed out afteractionTimeout), orENGINE_FAILURE(the browser connection was lost). All three are already indocs/reference/errors.mdx.Why
To check a page for console errors or uncaught errors, test authors had to add an init script that wrapped
console.errorand listened forerrorandunhandledrejection, then read the results back withevaluate.How it works
Both methods read Playwright's per-page lists for the active tab with
{ filter: 'all' }(packages/web/src/browser.ts:710). With Playwright's default ('since-navigation'), entries would be dropped at each navigation. Playwright keeps the latest 200 entries per list. The list also has messages the browser writes, such as Chromium'sFailed to load resource.The calls are recorded as
browser.consoleMessagesandbrowser.pageErrorssteps without a label (packages/web/src/browser.ts:1029). Only the method name is recorded, not its return value. Console output can still appear in the app log, and a failed assertion can include the values it compared.WebConsoleMessageandWebPageErrorare exported from the main andengineentries (packages/web/src/browser.ts:127,packages/web/src/engine-entry.ts:38).typeis a union written out in the source. It includes Playwright'sConsoleMessage.type()union plus the extra values browsers can send:'verbose': level for Chromium browser messages, from CDP'sLog.entryAdded(coreBundle.js:39722).'countReset','timeLog', and'timeStamp': Firefox's Juggler maps each console method to a type (consoleLevelToProtocolTypein Juggler'scontent/Runtime.js, in the Firefox 1572 build), and Playwright passes it through (coreBundle.js:47062and:47115).'image'and'': WebKit'sConsole.ConsoleMessage.type, which is optional (coreBundle.js:48507and:49043, andsrc/server/webkit/protocol.d.tsin Playwright v1.65.1).Chromium's
Runtime.consoleAPICalleddoesn't add any values. The WebDriver BiDi path (coreBundle.js:43650) can't be reached fromweb(). If a Playwright bump adds a value, the build fails attype: message.type()(packages/web/src/browser.ts:713). Both return types, thetypevalues, and the lack of a filter option are pinned inpackages/web/tests/types/console-messages.ts.pageErrors()returns each Playwright error'sname,message, andstack(packages/web/src/browser.ts:718). Playwright splits the browser's error text at its first colon (splitErrorMessage,coreBundle.js:9628), so a rejected'Request failed: 500'has the name'Request failed'and the message'500'. AnErrorhas its class name, such as'Error'or'TypeError'.A persistent browser (
connect.reconnectEndpoint, or a provider inattemptscope) reuses its first tab, and Chrome replays that tab's earlier console output and errors to every new CDP client. Both lists are cleared before navigating toabout:blank, so entries from the context's init scripts are kept (packages/web/src/attempt-session.ts:328).After a CDP reconnect, Chrome only replays entries from the current document. Keeping earlier entries would mean carrying them over from the closed connection, so the limit is documented under "Recovering a CDP transport" instead.
The newsletter benchmark test reads
browser.consoleMessages()in place of the console hook it injected withbrowser.evaluate(apps/web-benchmark/tests/newsletter-signup.e2e.ts:14).Verified
Ran it locally: yes, on Chromium and Firefox 159.
Chromium:
packages/web/tests/integration/console-messages.test.ts,pnpm --filter @e2e-dev/web exec vitest run tests/integration/console-messages.test.ts --reporter verbose:initial.clearConsoleMessages()deleted (before the attemptcomes back), and with the clear calls moved after theabout:blanknavigation (only onefrom init scriptmessage comes back).node node_modules/e2e/dist/cli/bin.js run tests/browser.e2e.ts. The new test logs withconsole.error, leaves a rejection unhandled, and throws from a timer. All three are read back, and the lists are empty afterapp.restart():node node_modules/e2e/dist/cli/bin.js run tests/newsletter-signup.e2e.tsafterpnpm run build:Firefox, with
browser: 'firefox'added to the engine options locally (not committed):console-messages.test.ts: 5 of 7 pass. The persistent-tab test can't run there, sinceconnectis Chromium-only (INVALID_CONFIG). The test for values that aren't anErrorfails on itsstack: ''expectation, because Firefox reports a stack for them (uncaught exception: 7and the frames). That still matches thestackdoc ("as the browser reports it").tests/browser.e2e.ts: 7 passed, the new test included.Failed to load resourcefor a 404. It logs other warnings instead, such as[JavaScript Warning: "This page is in Quirks Mode..."]for a page without a doctype. TheconsoleMessagesentry covers both browsers, with Chromium's message as the example.Not captured:
pnpm bench:abwasn't run. The cost of clearing both lists when a persistent browser's first tab is reused wasn't measured.docs/reference/web.mdxand the Playwright, Cypress, and Selenium migration guides) can't be rendered locally.Checklist
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it..d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures.e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.