feat(click): add --js-click flag for DOM-level element.click()#1072
Open
Hyeong-soo wants to merge 1 commit intovercel-labs:mainfrom
Open
feat(click): add --js-click flag for DOM-level element.click()#1072Hyeong-soo wants to merge 1 commit intovercel-labs:mainfrom
Hyeong-soo wants to merge 1 commit intovercel-labs:mainfrom
Conversation
CDP Input.dispatchMouseEvent (coordinate-based) silently fails on: - SPA routers (React Router, Next.js, Vue Router) - Elements with pointer-events: none - Elements outside the viewport The new --js-click flag uses Runtime.callFunctionOn to call element.click() directly, bypassing the coordinate system. This mirrors the existing js_click_checkbox() fallback used by check()/uncheck() (interaction.rs L550), generalized for any clickable element. Fixes vercel-labs#1011 Addresses vercel-labs#1044
Contributor
|
@Hyeong-soo is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
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.
Problem
`click` uses CDP `Input.dispatchMouseEvent` which dispatches coordinate-based mouse events. This silently fails when:
The command reports success, but the intended element is not actually clicked. Related: #1011, #1044.
Note: SPA router click issues observed in v0.22.x appear to be resolved in v0.23.0. This PR addresses the remaining cases where coordinate-based clicking is fundamentally insufficient.
Root Cause
`Input.dispatchMouseEvent` operates at the browser input pipeline level (coordinates → hit-test → element). CSS properties like `pointer-events: none` cause the hit-test to resolve to a different element than intended, and viewport-obscured elements produce unreliable coordinates.
`element.click()` (DOM API) bypasses the coordinate system entirely and invokes the element's click handler directly, which is immune to CSS pointer restrictions and viewport position.
Changes
Behavior
Testing
```bash
cargo test --manifest-path cli/Cargo.toml # 542 passed, 0 failed
cargo fmt --manifest-path cli/Cargo.toml -- --check
Manual verification (pointer-events: none):
agent-browser open https://vercel.com
agent-browser snapshot -i
agent-browser click @e91 # Docs link — URL unchanged
agent-browser click @e91 --js-click # URL → /docs ✅
```