Skip to content

feat(headless): render element locators before lookup - #7549

Merged
Mzack9999 merged 1 commit into
devfrom
dwisiswant0/feat/headless/render-element-locators-before-lookup
Jul 16, 2026
Merged

feat(headless): render element locators before lookup#7549
Mzack9999 merged 1 commit into
devfrom
dwisiswant0/feat/headless/render-element-locators-before-lookup

Conversation

@dwisiswant0

@dwisiswant0 dwisiswant0 commented Jul 15, 2026

Copy link
Copy Markdown
Member

Proposed changes

Render locator arguments thru the action renderer
for every element lookup mode (selector, regex,
XPath, JavaScript, and search locators). Keep
rendered values local and reuse selectors instead
of rendering them twice.

Render waitvisible locators on the owning page
so Interactsh URLs remain attached to the request.
Use a local URL source in tests to avoid network
access.

Closes #7542

Proof

Checklist

  • Pull request is created against the dev branch
  • All checks passed (lint, unit/integration/regression tests etc.) with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Summary by CodeRabbit

  • Bug Fixes
    • Improved headless browser element targeting across selector, regex, XPath, JavaScript, and search-based actions.
    • Wait-visible actions now report element lookup failures correctly.
    • Improved handling of dynamically rendered selectors and template-based element targets.
    • Interactsh URL placeholders are rendered and tracked more reliably during browser actions.

Render locator arguments thru the action renderer
for every element lookup mode (selector, regex,
XPath, JavaScript, and search locators). Keep
rendered values local and reuse selectors instead
of rendering them twice.

Render `waitvisible` locators on the owning page
so Interactsh URLs remain attached to the request.
Use a local URL source in tests to avoid network
access.

Closes #7542

Signed-off-by: Dwi Siswanto <git@dw1.io>
@dwisiswant0
dwisiswant0 requested a review from Mzack9999 July 15, 2026 19:10
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 783b6e54-9cab-4f7c-94a8-6ea004fffb6c

📥 Commits

Reviewing files that changed from the base of the PR and between bcd5807 and 02e5a5d.

📒 Files selected for processing (3)
  • pkg/protocols/headless/engine/instance.go
  • pkg/protocols/headless/engine/page_actions.go
  • pkg/protocols/headless/engine/page_actions_test.go

Walkthrough

Headless element locators now render action arguments before lookup, return resolved selectors for relevant modes, propagate lookup errors, and use an Interactsh URL source interface. Tests cover template interpolation, Interactsh tracking, and dynamic selectors.

Changes

Headless locator rendering

Layer / File(s) Summary
Interactsh URL source contract
pkg/protocols/headless/engine/instance.go
Instance.interactsh now uses render.URLSource instead of a concrete Interactsh client.
Rendered locator resolution
pkg/protocols/headless/engine/page_actions.go
Element-targeting actions use the action-aware resolver, which renders locator arguments, returns selectors where applicable, and propagates lookup errors.
Locator and Interactsh validation
pkg/protocols/headless/engine/page_actions_test.go
Tests verify rendered locators, Interactsh URL generation and tracking, and template-driven click and wait-visible selectors.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant HeadlessAction
  participant pageElementBy
  participant getActionArg
  participant RodPage
  participant InteractshURLSource
  HeadlessAction->>pageElementBy: provide action locator
  pageElementBy->>getActionArg: render locator argument
  getActionArg->>InteractshURLSource: generate Interactsh URL when referenced
  InteractshURLSource-->>getActionArg: return OAST hostname
  getActionArg-->>pageElementBy: return resolved locator
  pageElementBy->>RodPage: locate element
  RodPage-->>pageElementBy: return element and selector
  pageElementBy-->>HeadlessAction: return lookup result or error
Loading

Suggested reviewers: dogancanbakir

Poem

A rabbit found a selector bright,
Rendered templates just right.
OAST trails hopped through the page,
Errors stepped onto the stage.
“Click and wait!” the bunny sings,
As lookup clarity takes wing.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: rendering headless element locators before lookup.
Linked Issues check ✅ Passed The changes align with #7542 by rendering locator arguments before lookup, preserving Interactsh tracking, and updating affected actions and tests.
Out of Scope Changes check ✅ Passed The diff stays focused on headless locator rendering and related tests, with no clear unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dwisiswant0/feat/headless/render-element-locators-before-lookup

Comment @coderabbitai help to get the list of available commands.

@Mzack9999
Mzack9999 merged commit a1291fa into dev Jul 16, 2026
19 checks passed
@Mzack9999
Mzack9999 deleted the dwisiswant0/feat/headless/render-element-locators-before-lookup branch July 16, 2026 07:18
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.

[BUG] Headless element locators do not support template interpolation

2 participants