[🐛 Bug]: aria/
selector fails when selecting an input related to a label when there are multiple inputs in the document
#12883
Labels
Have you read the Contributing Guidelines on issues?
WebdriverIO Version
latest
Node.js Version
v20.12.2
Mode
WDIO Testrunner
Which capabilities are you using?
What happened?
The XPath selector under
aria/
for finding aninput
ortextarea
related to alabel
do not function properly in cases where there are multiple elements. I have set up test cases for various scenarios, but basically the issue is this when we have a setup like this:If we want to find an input attached to the label
"Search 2"
, we would write$('aria/Search 2')
.Currently, that yields the first textarea containing
Hello World! 1
.The relevant XPath selectors are:
webdriverio/packages/webdriverio/src/utils/findStrategy.ts
Lines 180 to 181 in 82b3863
I'm no XPath XPert, but I believe this XPath is essentially saying:
In other words, the
//
is making XPath find every input in the document, so long as there is a label matching "Search 2".What we want is for it to say:
Removing the
//
fixes this issue in the tests.What is your expected behavior?
No response
How to reproduce the bug.
Run the
e2e
test suitelit
tests:Relevant log output
Before the fix
After the fix
Code of Conduct
Is there an existing issue for this?
The text was updated successfully, but these errors were encountered: