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.

[Question] Element is not attached to the DOM

See original GitHub issue

Hello,

I have a script like this. I randomly get Element is not attached to the DOM error when I run this.

await page.waitForSelector(selector);
const element = await page.$(selector);
await element.click();

Is it possible that the element disappears between the $ command and the click? If yes, how can I prevent this issue?

Thanks, Andras

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
iamandrascommented, Apr 21, 2021

Thanks for the explanation @dgozman. Makes sense, I’ve thought it works this way.

0reactions
dgozmancommented, Apr 21, 2021

Let me close this issue then. If you have any more questions, please comment here, and I’ll reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Playwright "Element is not attached to the DOM" - Stack Overflow
The element is selected successfully, but then when trying to run await input.CheckAsync() , I get the error Element is not attached to...
Read more >
webdriver - "Element is no longer attached to the DOM ...
An element that is found on a web page referenced as a WebElement in WebDriver then the DOM changes (probably due to JavaScript...
Read more >
Exceptions | Selenium
The element has been deleted entirely. The element is no longer attached to the DOM. The Element has been deleted. The most frequent...
Read more >
Using shadow DOM - Web Components | MDN
Shadow DOM allows hidden DOM trees to be attached to elements in the regular DOM tree — this shadow DOM tree starts with...
Read more >
Stale Element Reference Exception in Selenium Webdriver ...
Cause 2: The referenced element is no longer attached to the DOM ... Assume a document node is removed from the DOM, its...
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