browser.execute doesn't refetch element
See original GitHub issueEnvironment (please complete the following information):
- WebdriverIO version: 5.16.5
Describe the bug A clear and concise description of what the bug is.
To Reproduce
browser.url("http://guinea-pig.webdriver.io")
const el = $('.box')
browser.refresh()
browser.execute(el => el, el)
Expected behavior
browser.execute
should refetch element
Log
stale element reference: element is not attached to the page document (Session info: headless chrome=78.0.3904.108)
Additional context
Using el.isExisting()
doesn’t help neither because it’s not updating element id to the new one (and I’m not sure if t actually should)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
execute method's element argument is not translated to ...
When a webElement reference is passed as an argument in execute method, it is not converted to the corresponding DOM element in the...
Read more >ajax - When does the browser execute Javascript? How does ...
The answer varies depending on where the script tag is and how you've added it: Script tags inline with your markup are executed...
Read more >webdriverio/webdriverio - Gitter
Hello all, is it possible to inject javascript functions (as strings) and reuse them with browser.executeScript and browser.execute()?. Christian Bromann.
Read more >execute | API Reference - Nightwatch.js
execute (). Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame. The executed script...
Read more >click - WebdriverIO
To work around this, try to find the overlaying element and remove it via execute command so it doesn't interfere the click. You...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Also reproducible for
staleElement.scrollIntoView()
, as it usesbrowser.execute
under the hood 😦I mean that currently the command is failing because element is stale. This is a way to understand that element has changed. If we fix the issue by adding middleware that would silently refetch the element how can I identify if element has changed or not?
Forget it, it should be possible by comparing element id