`wait_for` never finds visible text whose HTML source contains line breaks or repeated spaces
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- testing-qa
Research direction
Start with McpPage.waitForTextOnPage in src/McpPage.ts:1132-1149 and the wait_for description and tests in src/tools/snapshot.ts:49-61. Reproduce using the supplied /spaces.html fixture and compare wait_for with the snapshot text. Done when normalized paragraph text succeeds, the button still succeeds, and absent text still times out.
Written by the indexing model from the issue text.
Description
Description of the bug
wait_for times out on text that is visible on the page and shown verbatim in take_snapshot when the element's HTML source contains a line break, indentation or repeated spaces inside the text. For <p>Order\n confirmed</p>, the snapshot shows StaticText "Order confirmed", but wait_for with ["Order confirmed"] fails with Timed out after waiting 2000ms. Source formatting like this is common in real pages, and agents naturally copy text from the snapshot, so wait_for reports a timeout for content that is already on screen. Both tested builds behave the same.
Actual behavior
Identical on both builds:
take_snapshot
uid=2_1 StaticText "Multi spaced words"
uid=2_2 StaticText "Order confirmed"
uid=2_3 button "Place order"
wait_for ["Multi spaced words"] isError=true ~2003 ms "Error: Timed out after waiting 2000ms"
wait_for ["Order confirmed"] isError=true ~2003 ms "Error: Timed out after waiting 2000ms"
wait_for ["Place order"] isError=false 8-10 ms "Element matching one of [\"Place order\"] found."
(The main build prints snapshot text nodes without the StaticText role label; the strings are the same.) The button matches because its accessible name is whitespace-normalized; the paragraphs have no accessible name and only the raw-text match is tried.
Reproduction
- Serve this page as
/spaces.html(the second paragraph and the button contain a newline followed by four spaces):
<!doctype html><title>Spaces</title>
<p>Multi spaced words</p>
<p>Order
confirmed</p>
<button>Place
order</button>
- Send these calls in order:
{"name":"navigate_page","arguments":{"pageId":1,"url":"http://127.0.0.1:PORT/spaces.html"}}
{"name":"take_snapshot","arguments":{"pageId":1}}
{"name":"wait_for","arguments":{"pageId":1,"text":["Multi spaced words"],"timeout":2000}}
{"name":"wait_for","arguments":{"pageId":1,"text":["Order confirmed"],"timeout":2000}}
{"name":"wait_for","arguments":{"pageId":1,"text":["Place order"],"timeout":2000}}
The button is a control. Ran once per build for this report; an earlier independent run of the repeated-spaces paragraph timed out the same way on both builds.
Expectation
wait_for is described as "Wait for the specified text to appear on the selected page." with text "Resolves when any value appears on the page." (src/tools/snapshot.ts:49-61 at the main commit; docs/tool-reference.md). The page renders these paragraphs as "Multi spaced words" and "Order confirmed", and the server's own snapshot reports exactly those strings. Text that appears on the page as rendered, and as the snapshot shows it, should satisfy wait_for.
MCP configuration
--headless --isolated --no-usage-statistics --no-performance-crux unless the reproduction states otherwise (update checks disabled with CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1).
Chrome DevTools MCP version
1.10.1 (npm) and main 5ddb0a3110c5059f8e5513e566196cce2a35c6d1 (local build)
Chrome version
154.0.8037.98 (stable)
Node version
v22.23.2
Operating system
macOS 27.0
Environment details
- chrome-devtools-mcp 1.10.1 from npm (the release build).
- chrome-devtools-mcp built from
mainat commit 5ddb0a3110c5059f8e5513e566196cce2a35c6d1 (themainbuild; its server info still reports version 1.10.1). - Google Chrome 154.0.8037.98 stable, headless; Node v22.23.2; macOS 27.
- Both builds were started with
--headless --isolated --no-usage-statistics --no-performance-cruxandCHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1, and driven by a scripted stdio MCP client that sends onetools/callat a time and recordsisErrorand wall time. Fixtures were served from a loopback HTTP server on an ephemeral port (PORTbelow); any static server, such aspython3 -m http.server --bind 127.0.0.1, serves the static fixtures the same way.
Evidence
- Expected source:
wait_fordescription andtextparameter text (src/tools/snapshot.ts:49-61at themaincommit); the strings in the same server'stake_snapshotoutput. - Failure source: scripted MCP run above on both builds. Static breadcrumb (inferred from source and the button control):
McpPage.waitForTextOnPage(src/McpPage.ts:1132-1149) racesaria/<text>(accessible name, normalized) andtext/<text>(DOM text content, not whitespace-collapsed) locators, so text in non-named elements must match the source whitespace exactly. - Evidence provenance: observed
- Local verification: reproduced
- Reproduction completeness: complete
Fix check
With the steps above, wait_for with ["Order confirmed"] and with ["Multi spaced words"] each return success promptly. Controls that pass today on both builds and must keep passing: ["Place order"] still succeeds, and a string that is not on the page (["Order cancelled"]) still times out.
Additional context
The full open and closed issue and PR corpus was screened as of 2026-10-06 (searches included wait_for whitespace, wait_for text); no issue reports this.
Two other wait_for mismatches with the snapshot were observed in the same investigation and are reported separately because each has its own failing input: text hidden with display:none is reported as found, and text inside an iframe attached after the call starts is never found.
- Dominant language
- TypeScript
- Stars
- 54.6k
- Forks
- 5.2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 218
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ChromeDevTools/chrome-devtools-mcp
-
Truncating a page URL can split a percent-encoded characterPossibly taken @axchadxs claimed this 6 days ago. Openconfirmed p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ChromeDevTools/chrome-devtools-mcp#3340 · 1 comment ·
Maintainers usually reply within 1 day
-
collecting-feedback feature
Difficulty 2/5 Half a day Newbie friendliness 76/100
ChromeDevTools/chrome-devtools-mcp#3225 · 3 comments ·
Maintainers usually reply within 1 day
-
confirmed p3
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
ChromeDevTools/chrome-devtools-mcp#3089 · 2 reactions ·
Maintainers usually reply within 1 day
-
`resize_page` reports success when the page does not end up at the requested sizePossibly taken @SU-AN-coder claimed this 2 days ago. Openconfirmed p3
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
ChromeDevTools/chrome-devtools-mcp#2998 ·
Maintainers usually reply within 1 day
-
Client roots from a WSL2 client are dropped by a Windows-side server (fileURLToPath ERR_INVALID_FILE_URL_PATH)Possibly taken @nroscino claimed this 30 days ago. Openconfirmed p3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ChromeDevTools/chrome-devtools-mcp#2839 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
All issues in ChromeDevTools/chrome-devtools-mcp
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NousResearch/hermes-agent#147433 ·
Maintainers usually reply within 1 day
-
needs-triage🔍
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Dokploy/dokploy#5836 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ehmpathy/rhachet-roles-bhrain#739 ·
Maintainers usually reply within 1 day