question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

browser.execute doesn't refetch element

See original GitHub issue

Environment (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:open
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vgrigorukcommented, Nov 24, 2020

Also reproducible for staleElement.scrollIntoView(), as it uses browser.execute under the hood 😦

0reactions
mgrybykcommented, Nov 26, 2019

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found