Skip to content

feat: report navigated URL in action responses#1954

Open
masamaru0513 wants to merge 1 commit intoChromeDevTools:mainfrom
masamaru0513:feat/report-navigated-url
Open

feat: report navigated URL in action responses#1954
masamaru0513 wants to merge 1 commit intoChromeDevTools:mainfrom
masamaru0513:feat/report-navigated-url

Conversation

@masamaru0513
Copy link
Copy Markdown
Contributor

@masamaru0513 masamaru0513 commented Apr 24, 2026

Summary

Report the new page URL when an action triggers a navigation, so there is no need to re-query the pages list.

Fixes #243

Note: I am aware of the existing #1853 which addresses the same issue. This PR incorporates the review feedback from #1853 (by @Lightning00Blade) — specifically using navigatedToUrl naming, extracting a shared appendNavigatedToUrl helper in WaitForHelper, and applying it to evaluate_script as well.

Changes

  • McpPage.waitForEventsAfterAction now compares the page URL before and after the action, returning {navigatedToUrl} when a navigation occurred
  • Added appendNavigatedToUrl helper in WaitForHelper.ts for consistent URL reporting across tools
  • All input tools (click, click_at, hover, fill, fill_form, type_text, drag, press_key) use the helper to append Navigated to <URL> when a navigation is detected
  • evaluate_script also reports navigated URLs using the same helper
  • navigate_page (url type) now reports the final URL after redirects instead of the requested URL
  • new_page now reports the navigated URL in the response message

Output example

Before:

Successfully clicked on the element

After:

Successfully clicked on the element
Navigated to https://www.iana.org/help/example-domains

Testing

  • Unit tests added for:
    • Click triggering navigation → reports URL
    • Click without navigation → no "Navigated to" in response
    • navigate_page reports final URL
  • Manual verification:
    • click on a link → reports navigated URL ✅
    • press_key Enter on a focused link → reports navigated URL ✅
    • evaluate_script with window.location.href change → reports navigated URL ✅
    • evaluate_script without navigation → no "Navigated to" ✅
    • navigate_page reports final URL (with trailing slash after redirect) ✅
    • Hash-only change (anchor link) → no "Navigated to" (same-document navigations are excluded by WaitForHelper) ✅
    • navigate_page back/forward → existing behavior preserved ✅

@masamaru0513 masamaru0513 force-pushed the feat/report-navigated-url branch from d58c34c to ccf84a8 Compare April 24, 2026 13:05
Report the new page URL when an action (click, fill, press_key, etc.)
triggers a navigation. The URL is detected by comparing the page URL
before and after waitForEventsAfterAction.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Actions that result in a navigation should report the new page URL in the response

1 participant