[BUG] Unable to adopt element handle from a different document
See original GitHub issueContext:
- Playwright Version: 1.2.1
- Operating System: Mac
- Node version: v12.16.3
- Browser: Chromium
Code Snippet
const { chromium } = require("playwright-chromium");
(async () => {
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();
await page.goto("https://haircuttery.com");
await page.click("#salonSearch-header");
await page.fill("#salonSearch-header", "59718");
await page.click("#submit");
await page.click(
'[href="/client/checkin.html?reqType=newappointment&salonid=4390"]'
);
// error here
await page.waitForSelector("html");
})();
Describe the bug
We want to get the html element to scroll it. However we are unable to get the element since it fails with this error: await page.waitForSelector("html");
fails with “Unable to adopt element handle from a different document”
pw:api waiting for scheduled navigations to finish [] +0ms
pw:api navigated to "https://haircuttery.com/client/checkin.html?reqType=newappointment&salonid=4390" [] +261ms
pw:api navigations have finished [] +3ms
pw:api <= page.click succeeded +0ms
pw:api => page.waitForSelector started +1ms
pw:api waiting for selector "html" to be visible [] +0ms
pw:api selector resolved to visible <html lang="en">…</html> [] +48ms
pw:api <= page.waitForSelector failed +312ms
(node:91208) UnhandledPromiseRejectionWarning: Error: Unable to adopt element handle from a different document
================ page.waitForSelector logs ================
[api] waiting for selector "html" to be visible
[api] selector resolved to visible <html lang="en">…</html>
============================================================
Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs.
at FrameSession._adoptBackendNodeId (/Users/jon/dev/examples/pw-core/node_modules/playwright-chromium/lib/chromium/crPage.js:745:19)
at runMicrotasks (<anonymous>)
at runNextTicks (internal/process/task_queues.js:62:5)
at processImmediate (internal/timers.js:429:9)
at async /Users/jon/dev/examples/pw-core/node_modules/playwright-chromium/lib/frames.js:394:33
at async ProgressController.run (/Users/jon/dev/examples/pw-core/node_modules/playwright-chromium/lib/progress.js:77:28)
at async /Users/jon/dev/examples/pw-core/haircuttery.js:13:3
-- ASYNC --
at Frame.waitForSelector (/Users/jon/dev/examples/pw-core/node_modules/playwright-chromium/lib/helper.js:78:23)
at /Users/jon/dev/examples/pw-core/node_modules/playwright-chromium/lib/page.js:131:61
at Page._attributeToPage (/Users/jon/dev/examples/pw-core/node_modules/playwright-chromium/lib/page.js:356:20)
at Page.waitForSelector (/Users/jon/dev/examples/pw-core/node_modules/playwright-chromium/lib/page.js:131:21)
at Page.waitForSelector (/Users/jon/dev/examples/pw-core/node_modules/playwright-chromium/lib/helper.js:79:31)
at /Users/jon/dev/examples/pw-core/haircuttery.js:13:14
at runNextTicks (internal/process/task_queues.js:62:5)
at processImmediate (internal/timers.js:429:9)
(node:91208) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:91208) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:12 (7 by maintainers)
Top Results From Across the Web
getting a handle on an element in the context of another
But what I need is a handle on the label element so that I can get its sibling field so I can type...
Read more >feature(evaluate): support cross-context element handles (#295)
throw new Error('Unable to adopt element handle from a different document');, throw new Error('Unable to adopt element handle from a different document');.
Read more >ElementHandle class - Puppeteer
ElementHandle prevents the DOM element from being garbage-collected unless the handle is disposed. ElementHandles are auto-disposed when their origin frame ...
Read more >WebDriver - W3C
WebDriver is a remote control interface that enables introspection and control of user agents. It provides a platform- and language-neutral ...
Read more >Dropping and Adding Online Classes - Confluence
Issuing Office. Registrar's Office. Affected Parties. Students. Policy Language. Liberty University Online students may register for courses online through ...
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 FreeTop 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
Top GitHub Comments
Hey! I have the same issue but with different details. I’ll try to provide them:
Context: Playwright Version: 1.10.0 Jest-playwright-preset: ~1.5.2 Operating System: Ubuntu Node version: v12.13.0 Browser: Chromium
Code Snippet
This code uses readMetadata helper. Here this mistakes comes:
Describe the bug
or at the same place sometimes happens one more problem:
Sorry it’s a weird reproduction, just something I encountered using playwright on random sites. This is a slightly more robust selector that is not geographically dependent.