Skip to content

Fix - vibium:element.text returns innerText instead of textContent - #216

Closed
Jhoan0714 wants to merge 2 commits into
VibiumDev:mainfrom
Jhoan0714:fix/element-text-textcontent
Closed

Fix - vibium:element.text returns innerText instead of textContent#216
Jhoan0714 wants to merge 2 commits into
VibiumDev:mainfrom
Jhoan0714:fix/element-text-textcontent

Conversation

@Jhoan0714

@Jhoan0714 Jhoan0714 commented Jul 8, 2026

Copy link
Copy Markdown

Summary

This PR fixes #215 the vibium:element.text wire handler so el.text() returns text content (textContent) instead of inner text (innerText), matching docs/reference/api.md and the handler comment in Go.

Root Cause

handleVibiumElText in clicker/internal/api/handlers_state.go evaluated (el.innerText || '').trim() even though the comment and API docs describe textContent behavior. As a result, el.text() behaved identically to el.inner_text() for elements with hidden descendants.

Why this matters

  • Restores the documented distinction between text() and inner_text() / innerText()
  • Fixes silent wrong data for scraping, tabs/accordions, and accessibility-hidden content
  • Aligns Python/JS/Java client behavior with the API reference (row 80 vs 81 in api.md)

Validation

Executed:

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()

Before fix:

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."

After fix:

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.Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using \'Content here, content here\', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for \'lorem ipsum\' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).More"

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."

@hugs

hugs commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for this! #215 was fixed in #273, so element.text returns textContent on main now. Closing this out.

@hugs hugs closed this Aug 3, 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.

vibium:element.text returns innerText instead of textContent

2 participants