Skip to content

Add scraping_browser_hover_ref and a force option for click_ref - #206

Merged
romanv-brd merged 1 commit into
brightdata:mainfrom
Rutvij97:feat/browser-hover-force-click
Dec 1, 2026
Merged

romanv-brd merged 1 commit into
brightdata:mainfrom
Rutvij97:feat/browser-hover-force-click

Conversation

@Rutvij97

Copy link
Copy Markdown
Contributor

Problem

scraping_browser_click_ref always calls locator.click({timeout: 5000}), so there is no way to skip Playwright's actionability checks, and there is no tool to hover an element. Content that only appears on hover (menus, tooltips, jsaction="mouseenter:..." badges) can't be reached.

Change

  • New scraping_browser_hover_ref (ref, element) calls locator.hover({timeout: 5000}). It is in the browser group, manifest.json, the README table and assets/Tools.md. Its annotations match scraping_browser_scroll_to_ref (read-only, not destructive, open world).
  • scraping_browser_click_ref takes an optional force boolean that is passed to locator.click. The default is false, so the current behaviour doesn't change.

One note on force: it skips the stable, enabled and not-covered checks, but Playwright still sends the click at the element's position. If another element covers the target, the covering element receives the click. The parameter description and the docs say so, and a test pins this behaviour so agents aren't told that force clicks "through" an overlay. For a cover like the one in #205, hovering first (to open what the widget expects) is the more likely fix.

Tests

New test/browser-hover-force.test.js:

  • A schema test for both tools.
  • A real-browser test that follows test/browser-session-references.test.js: local Chromium over CDP, with refs from a filtered snapshot. It calls each tool's own execute. The credential lookup is answered in-process by an axios adapter, and ref_locator resolves on the local page, so there are no network calls. It checks:
    • hover reveals a CSS :hover menu item that then appears in a new snapshot and can be clicked
    • hover fires mouseenter handlers
    • a normal click on an aria-disabled button fails with "not enabled", and force: true clicks it
    • a normal click on a covered button fails with "intercepts pointer events", and force: true lands on the cover

The two force cases fail if force isn't passed through.

Commands run locally (Node 22.17):

  • node --test test/browser-hover-force.test.js test/annotations.test.js test/browser-session-references.test.js test/package-files.test.js: 24 passed, 0 failed
  • npm test: 201 passed, 1 failed, 14 cancelled, 7 skipped. On main it is 200 passed, 1 failed, 14 cancelled, 6 skipped, with the same failures:
    • test/packed-install.test.js fails because the local npm install returns ETARGET for playwright-core@1.64.1
    • the test/search-utils.test.js tests are cancelled with "Promise resolution is still pending" under Node 22 (CI uses Node 24)

The Chromium build that Playwright 1.64.1 expects isn't installed on my machine, so I ran the real-browser tests with Playwright's cached headless shell through a local --import preload. That preload isn't part of this PR. In CI, npx playwright install --with-deps chromium provides the browser and the test runs as written.

Closes #205

Hover moves the mouse over an element by ref so menus, tooltips and
other content shown on hover can be opened. click_ref takes an optional
force that skips Playwright's actionability checks; the click is still
sent at the element's position.

Closes brightdata#205
@romanv-brd
romanv-brd force-pushed the feat/browser-hover-force-click branch from 58297c5 to 7d3c83c Compare December 1, 2026 09:53
@romanv-brd
romanv-brd merged commit 0585d9d into brightdata:main Dec 1, 2026
1 check passed
@romanv-brd

Copy link
Copy Markdown
Collaborator

merged, thank you !

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.

Expose Playwright's force click option and hover action via the MCP tools

2 participants