Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

test: avoid false positives in xpath @class tests #213

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

cwillisf
Copy link
Contributor

@cwillisf cwillisf commented Mar 5, 2025

Proposed Changes

In selenium-helper.js, adjust XPath expressions that inspect @class to check for word boundaries.

Reason for Changes

The @class attribute can have multiple space-separated values, like "foo2 bar baz" for example. The previous code would check for contains(@class, "foo") which, if intended to check for the "foo" class, would return a false positive in that case. The new code tests for contains(concat(" ", @class, " "), " foo ") -- in other words, it checks if " foo2 bar baz " contains " foo ", which would correctly return false in this example.

I ran into this while updating our tests for the new version of Blockly: a false positive @class test was causing an integration test to fail because it attempted to click on the wrong element.

Test Coverage

Covered by existing tests.

@cwillisf cwillisf requested a review from a team as a code owner March 5, 2025 17:12
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant