{{ message }}
fix: preserve empty accessibility name (ax_node.name) instead of dropping it#5075
Open
kaXianc2-gom wants to merge 2 commits into
Open
fix: preserve empty accessibility name (ax_node.name) instead of dropping it#5075kaXianc2-gom wants to merge 2 commits into
kaXianc2-gom wants to merge 2 commits into
Conversation
…ping it
When ax_node.name is an empty string (''), the truthiness check
'if ax_node.name:' evaluates to False, causing valid empty accessibility
names to be silently dropped. This affects dom element hashing, hidden
element text collection, interacted element loading, and agent selectors.
Changed 5 instances of 'if .ax_node.name:' to 'if .ax_node.name is not None:'
to correctly distinguish between an absent name (None) and an explicitly
empty name (''), which carries different semantic meaning in accessibility
trees.
Files changed:
- browser_use/dom/views.py (3 occurrences in hashing methods)
- browser_use/dom/service.py (1 occurrence in hidden element text collection)
- browser_use/agent/service.py (1 occurrence in debugging ax_names filter)
Co-Authored-By: Claude <noreply@anthropic.com>
Three new tests verify: - Empty string ax_node.name is preserved as ax_name='' (not dropped to None) - None ax_node.name is correctly kept as ax_name=None - Elements with empty name vs no name produce different hashes Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

AI Assistance Disclosure
This contribution was developed with AI assistance (Claude / Anthropic Claude Code).
Summary
When
ax_node.nameis an empty string (''), the truthiness checkif ax_node.name:evaluates toFalse, causing valid empty accessibility names to be silently dropped. An empty name and an absent name (None) carry different semantic meaning in accessibility trees.Changes
Changed 5 instances of
if .ax_node.name:toif .ax_node.name is not None:across 3 files:DOMInteractedElement.load_from_enhanced_dom_treeVerification Process
uv sync), ran existing test suitetests/ci/test_ax_name_matching.pyTest Results
Cross-Validation
ax_node.name = None(no name)ax_node.name = ''(empty name)ax_node.name = 'Submit'(normal)ax_node = None(no ax_node)Closes #5041