-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
WebdriverIO Version
latest
Node.js Version
20
Mode
Standalone Mode
Which capabilities are you using?
{
"browserName": "firefox"
}What happened?
We issue the commands
const wrapper = $('[data-testid="wrapper"]')
const nested = wrapper.$('[data-testid="wrapper-nested"]')The nested is retrieved from the root, instead of from nested within wrapper, which brings us a different element !
This happens because internally we get an error:
WebDriver Bidi command "browsingContext.locateNodes" failed with error: no such node - The node with the reference (wrapper reference) is not known, falling back to regular WebDriver Classic command
Which then executes a normal WebDriver classic but from the root of the page, losing the wrapper parent context, which retrieves a different element !
Classic method is executing a find from the root
Using URL http://localhost:65260/session/${sessionURL}/element
instead of http://localhost:65260/session/${sessionURL}/element/${refetchedElementReference}/element
Here is the offending line of code:
| return browser.findElement(using, value) |
findElements in called from browser, without parent nesting context !
What is your expected behavior?
Element nesting and parent context should be respected !
How to reproduce the bug.
Observed in Firefox.
Conditions tricky to implement due to staleness of elements but solution is not: Element context should be preserved when calling WebDriver Classic method !
Relevant log output
Here we give a command to find [data-testid="wrapper-nested"] which is located inside a [data-testid="wrapper"]
INFO webdriver: DATA { using: 'css selector', value: '[data-testid="wrapper-nested"]' }Since this is BiDi v9, browsingContext.locateNodes attempts to find it, with the correct context, the element reference for the wrapper is sent in startNodes
INFO webdriver: BIDI COMMAND browsingContext.locateNodes {
"locator": {
"type": "css",
"value": "[data-testid=\"wrapper-nested\"]"
},
"context": "437e2afe-fd61-4568-af88-26ff1e51ac1e",
"startNodes": [
{
"sharedId": "97e6478d-2fd9-45d3-acfc-ad162ae362a4"
},
{
"sharedId": "3ae62490-0013-4583-aad7-2fe8fbf1660c"
}
]
}Then it fails, due to unknown reference to the wrapper element (97e6478d-2fd9-45d3-acfc-ad162ae362a4)
Possibly a stale element, then falls back to WebDriver classic
2024-09-11T14:51:44.626Z WARN webdriverio: Failed to execute browser.browsingContextLocateNodes({ ... }) due to
Error: WebDriver Bidi command "browsingContext.locateNodes" failed with error:
no such node - The node with the reference 97e6478d-2fd9-45d3-acfc-ad162ae362a4 is not known,
falling back to regular WebDriver Classic command
And here lies the problem, Classic method is executing a find from the root
Using URL http://localhost:65260/session/${sessionURL}/element
instead of http://localhost:65260/session/${sessionURL}/element/${refetchedElementReference}/element
2024-09-11T14:51:44.626Z INFO webdriver: COMMAND findElement("css selector", "[data-testid="wrapper-nested"]")
2024-09-11T14:51:44.626Z INFO webdriver: [POST] http://localhost:65260/session/76788a73-a7c1-4c90-94dc-67f478e3d2a2/element
2024-09-11T14:51:44.626Z INFO webdriver: DATA {
using: 'css selector',
value: '[data-testid="wrapper-nested"]'
}Code of Conduct
- I agree to follow this project's Code of Conduct
Is there an existing issue for this?
- I have searched the existing issues