Skip to content

Fix #108 - Semantic element interactions#109

Open
Jhoan0714 wants to merge 1 commit into
VibiumDev:mainfrom
Jhoan0714:fix/semantic-interactions-non-selector
Open

Fix #108 - Semantic element interactions#109
Jhoan0714 wants to merge 1 commit into
VibiumDev:mainfrom
Jhoan0714:fix/semantic-interactions-non-selector

Conversation

@Jhoan0714

@Jhoan0714 Jhoan0714 commented Apr 21, 2026

Copy link
Copy Markdown

Summary

This PR Fixes #108 a selector-resolution mismatch in interaction script builders for non-CSS element locators.

Vibium already supports semantic element discovery (xpath, role, text, label, etc.) and actionability checks follow that model.
However, several JS-backed interaction scripts re-resolved elements using CSS-only querySelector(selector), which fails when semantic/xpath locators are used and selector is empty.

Root Cause

actionability.go uses this branching philosophy:

  • CSS path only when !hasSemantic(ep) && ep.Selector != ""
  • semantic path otherwise

Some interaction builders in handlers_interaction.go did not mirror that rule and used CSS-only lookup in follow-up JS operations.

Changes

clicker/internal/api/handlers_interaction.go

  • Aligned interaction script path selection with actionability philosophy:
    • CSS path only for strict CSS selector cases
    • semantic path otherwise
  • Added shared script builder abstractions to avoid drift between CSS and semantic variants:
    • scriptConfig
    • buildScript(...)
    • useCSSInteractionScript(...)
    • shared JS body/open helpers

This keeps behavior consistent while reducing duplicated script assembly code.

tests/js/async/interaction.test.js

Added coverage for non-CSS locators:

  • Input methods

    • fill/clear with xpath-only locator
    • fill/clear with role+label locator
  • Select

    • selectOption with xpath-only locator
    • selectOption with semantic role locator
  • Focus

    • focus with xpath-only locator
    • focus with role+label locator
  • dispatchEvent

    • dispatchEvent with xpath-only locator
    • dispatchEvent with role+label locator
  • Checkbox

    • check/uncheck with xpath-only locator
    • check/uncheck with semantic role locator

Why this matters

This closes a real gap between element discovery and action execution, making semantic workflows reliable across interaction APIs and preventing regressions with explicit tests.

Validation

Executed:

node --test tests/js/async/interaction.test.js
image

@Jhoan0714 Jhoan0714 changed the title Fix semantic element interactions for non-CSS selectors Fix #108 - Semantic element interactions Apr 22, 2026
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 in interaction scripts with semantic locators

1 participant