Skip to content

fix: ignore text after a filtered element in HTMLElements - #1148

Merged
KazuCocoa merged 1 commit into
appium:masterfrom
RaphaelFakhri:fix/html-elements-text-after-filtered-element
Nov 6, 2026
Merged

KazuCocoa merged 1 commit into
appium:masterfrom
RaphaelFakhri:fix/html-elements-text-after-filtered-element

Conversation

@RaphaelFakhri

Copy link
Copy Markdown
Contributor

Summary

page class: ... in a web context (iOS and Android) and get_android_inspect(class_name) on HTML source raise NoMethodError: undefined method '[]=' for nil when the page has text after a matching element closes, for example <div><a href="/login">Sign in</a> or register</div> with page class: :a.

With a filter set, HTMLElements only pushes matching elements onto its stack. After the matching element closes, the stack is empty, @skip_element is still false, and characters writes the following text to @element_stack.last, which is nil.

This change makes characters ignore text when no element is on the stack. Unfiltered output does not change.

Closes #1147

How Has This Been Tested?

  • Added test_html_elements_ignores_text_after_filtered_element to test/regression_test.rb. It fails with NoMethodError without the fix and passes with it.
  • bundle exec rake test: 44 tests, 101 assertions, 0 failures, 0 errors.

Checklist

  • bundle exec rake rubocop

@KazuCocoa
KazuCocoa merged commit 6eb4baf into appium:master Nov 6, 2026
8 of 10 checks passed
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.

HTMLElements raises NoMethodError when a class filter is set and text follows a matching element

2 participants