test: avoid false positives in xpath @class tests #213
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.
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 forcontains(@class, "foo")
which, if intended to check for the"foo"
class, would return a false positive in that case. The new code tests forcontains(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.