Skip to content

vibium:element.text returns innerText instead of textContent #215

Description

@Jhoan0714

Summary

el.text() in Python/JS/Java returns the same value as el.inner_text() when they should differ. The root cause is vibium:element.text wire handler evaluates innerText instead of textContent.

There is a documentation vs implementation mismatch: the API reference and handler comments describe text() as returning text content (textContent), but the Go implementation reads innerText.

Note: It only has an impact when there is hidden text within a visible element

Impacted operations

  • el.text() (Python, JavaScript, Java)

Expected behavior

Per api.md (rows 80–81):

API DOM property Behavior
el.text() textContent All text in the element subtree, including hidden content
el.inner_text() / el.innerText() innerText Only visually rendered text

Actual behavior

In clicker/internal/api/handlers_state.go, handleVibiumElText use innerText:

// handleVibiumElText — comment says textContent, implementation uses innerText
script, args := buildElStateScript(ep, `(el.innerText || '').trim()`)

Root cause

The wire handler for vibium:element.text and the exported helper GetText both evaluate innerText instead of textContent, despite the handler comment and API docs describing text content behavior.
Affected code:

  • clicker/internal/api/handlers_state.gohandleVibiumElText (line 19)
  • clicker/internal/api/handlers_state.goGetText (line 831)

Reproduction (Python)

Environment

  • OS: macOS (darwin arm64)
  • vibium (PyPI or local): 26.5.31
  • Python: 3.9.x

Minimal repro

from vibium import browser

bro = browser.start(headless=True)
page = bro.new_page()
page.go("https://demoqa.com/tabs")
el = page.find(".tab-content")
text = el.text()
inner = el.inner_text()
print(f"el.text()       = {text!r}")
print(f"el.inner_text() = {inner!r}")
bro.stop()

Output

el.text()       = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."

el.inner_text() = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."

In Browser console

Image

Proposed fix

In clicker/internal/api/handlers_state.go, align the implementation with the documented API (textContent):

// func handleVibiumElText — change innerText to textContent
script, args := buildElStateScript(ep, `(el.textContent || '').trim()`)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions