Skip to content

[BUG] Firefox / Webkit: Unable to click element in iframe (Frame has been detached) #6453

Closed

Description

Context:

  • Playwright Version: 1.10.0
  • Operating System: Mac
  • Node.js version: v14.16.1
  • Browser: Firefox, WebKit
  • Extra: No

Code Snippet

    const element = await page.mainFrame().waitForSelector('frame[name="navframe"]');
    console.log('Loaded frame0 URL: ' + await element.getAttribute('src')); // I see the frame URL

    let frame12 =  page.frames().find(frame => frame.name() === 'navframe');
    await frame12.waitForLoadState('domcontentloaded');
    const element1 = await frame12.waitForSelector('text=Reports');
    console.log('Loaded frame1 URL: ' + await element1.getAttribute('text')); //I see the element text
  
   await Promise.all([
   await frame12.click('text=Reports', { delay: 2000  }),
   await page.waitForLoadState('networkidle')]

Describe the bug
Unable to click element in iframe. Trace indicates element is visible and clickable but unable to click the element due to "Frame has been detached" error. The same code is working in Chromium browser if i do try catch and retry the event for x number of times using while loop, it eventually succeeds but not in Firefox and Webkit.

I tried to click the element with Playwright Inspector opened but click didn't work.

Screen Shot 2021-05-06 at 5 33 09 PM

I am trying to migrate from Protractor to Playwright. Any help is appreciated.

pw:protocol SEND ► {"method":"Page.getContentQuads","params":{"frameId":"frame-4294967297","objectId":"id-76"},"id":159,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a"} +1ms
  pw:api   done scrolling +1ms
  pw:protocol SEND ► {"method":"Runtime.callFunction","params":{"functionDeclaration":"(utilityScript, ...args) => utilityScript.evaluate(...args)","args":[{"objectId":"id-49"},{"value":true},{"value":true},{"value":"() => ({ width: innerWidth, height: innerHeight })"},{"value":1},{"value":{"v":"undefined"}}],"returnByValue":true,"executionContextId":"id-41"},"id":160,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a"} +0ms
  pw:protocol ◀ RECV {"id":159,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a","result":{"quads":[{"p1":{"x":493.54998779296875,"y":46.68333435058594},"p2":{"x":613.5499877929688,"y":46.68333435058594},"p3":{"x":613.5499877929688,"y":67.01667022705078},"p4":{"x":493.54998779296875,"y":67.01667022705078}}]}} +0ms
  pw:protocol ◀ RECV {"id":160,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a","result":{"result":{"value":{"o":[{"k":"width","v":1600},{"k":"height","v":1024}]}}}} +1ms
  pw:protocol SEND ► {"method":"Page.describeNode","params":{"frameId":"frame-4294967297","objectId":"id-76"},"id":161,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a"} +0ms
  pw:api   checking that element receives pointer events at (553.54,56.85) +1ms
  pw:protocol ◀ RECV {"id":161,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a","result":{"ownerFrameId":"frame-4294967297"}} +1ms
  pw:protocol SEND ► {"method":"Runtime.callFunction","params":{"functionDeclaration":"(utilityScript, ...args) => utilityScript.evaluate(...args)","args":[{"objectId":"id-49"},{"value":true},{"value":false},{"value":"(injected, { parsed, scope }) => {\n            return injected.querySelectorAll(parsed, scope || document);\n        }"},{"value":2},{"value":{"h":0}},{"value":{"o":[{"k":"parsed","v":{"o":[{"k":"parts","v":{"a":[{"a":[{"o":[{"k":"simples","v":{"a":[{"o":[{"k":"selector","v":{"o":[{"k":"css","v":"iframe"},{"k":"functions","v":{"a":[]}}]}},{"k":"combinator","v":""}]}]}}]}]}]}},{"k":"capture","v":{"v":"undefined"}}]}},{"k":"scope","v":{"v":"undefined"}}]}},{"objectId":"id-48"}],"returnByValue":false,"executionContextId":"id-41"},"id":162,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a"} +1ms
  pw:protocol ◀ RECV {"id":162,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a","result":{"result":{"objectId":"id-85","type":"object","subtype":"array"}}} +3ms
  pw:protocol SEND ► {"method":"Runtime.getObjectProperties","params":{"executionContextId":"id-41","objectId":"id-85"},"id":163,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a"} +0ms
  pw:protocol ◀ RECV {"id":163,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a","result":{"properties":[]}} +1ms
  pw:protocol SEND ► {"method":"Runtime.disposeObject","params":{"executionContextId":"id-41","objectId":"id-85"},"id":164,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a"} +1ms
  pw:protocol SEND ► {"method":"Runtime.disposeObject","params":{"executionContextId":"id-42","objectId":"id-76"},"id":165,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a"} +0ms
  pw:protocol ◀ RECV {"id":164,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a"} +5ms
  pw:protocol ◀ RECV {"id":165,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a"} +0ms
  pw:channel:response {
  pw:channel:response   id: 30,
  pw:channel:response   error: {
  pw:channel:response     error: {
  pw:channel:response       message: 'Frame has been detached.\n' +
  pw:channel:response         '=========================== logs ===========================\n' +
  pw:channel:response         'waiting for selector "text=Reports"\n' +
  pw:channel:response         '  selector resolved to visible <td id="Col10" width="120" align="center" class="tab…>…</td>\n' +
  pw:channel:response         'attempting click action\n' +
  pw:channel:response         '  waiting for element to be visible, enabled and stable\n' +
  pw:channel:response         '  element is visible, enabled and stable\n' +
  pw:channel:response         '  scrolling into view if needed\n' +
  pw:channel:response         '  done scrolling\n' +
  pw:channel:response         '  checking that element receives pointer events at (553.54,56.85)\n' +
  pw:channel:response         '============================================================\n' +
  pw:channel:response         'Note: use DEBUG=pw:api environment variable to capture Playwright logs.',
  pw:channel:response       stack: 'Error: Frame has been detached.\n' +
  pw:channel:response         '=========================== logs ===========================\n' +
  pw:channel:response         'waiting for selector "text=Reports"\n' +
  pw:channel:response         '  selector resolved to visible <td id="Col10" width="120" align="center" class="tab…>…</td>\n' +
  pw:channel:response         'attempting click action\n' +
  pw:channel:response         '  waiting for element to be visible, enabled and stable\n' +
  pw:channel:response         '  element is visible, enabled and stable\n' +
  pw:channel:response         '  scrolling into view if needed\n' +
  pw:channel:response         '  done scrolling\n' +
  pw:channel:response         '  checking that element receives pointer events at (553.54,56.85)\n' +
  pw:channel:response         '============================================================\n' +
  pw:channel:response         'Note: use DEBUG=pw:api environment variable to capture Playwright logs.\n' +
  pw:channel:response         '    at FFPage.getFrameElement (/Users/testuser/research/e2e/node_modules/playwright/lib/server/firefox/ffPage.js:459:19)\n' +
  pw:channel:response         '    at processTicksAndRejections (internal/process/task_queues.js:93:5)\n' +
  pw:channel:response         '    at ElementHandle._checkHitTargetAt (/Users/testuser/research/e2e/node_modules/playwright/lib/server/dom.js:689:29)\n' +
  pw:channel:response         '    at ElementHandle._performPointerAction (/Users/testuser/research/e2e/node_modules/playwright/lib/server/dom.js:341:37)\n' +
  pw:channel:response         '    at ElementHandle._retryPointerAction (/Users/testuser/research/e2e/node_modules/playwright/lib/server/dom.js:284:28)\n' +
  pw:channel:response         '    at Frame._retryWithProgressIfNotConnected (/Users/testuser/research/e2e/node_modules/playwright/lib/server/frames.js:745:28)\n' +
  pw:channel:response         '    at /Users/testuser/research/e2e/node_modules/playwright/lib/server/frames.js:763:35\n' +
  pw:channel:response         '    at ProgressController.run (/Users/testuser/research/e2e/node_modules/playwright/lib/server/progress.js:79:28)\n' +
  pw:channel:response         '    at FrameDispatcher.click (/Users/testuser/research/e2e/node_modules/playwright/lib/dispatchers/frameDispatcher.js:94:16)\n' +
  pw:channel:response         '    at DispatcherConnection.dispatch (/Users/testuser/research/e2e/node_modules/playwright/lib/dispatchers/dispatcher.js:181:28)',
  pw:channel:response       name: 'Error'
  pw:channel:response     }
  pw:channel:response   }
  pw:channel:response } +52ms
  pw:api <= frame.click failed +13ms
  pw:api => page.screenshot started +0ms
  pw:channel:command {
  pw:channel:command   id: 31,
  pw:channel:command   guid: 'Page@e954c72e524b9d734b2b12dd832e60ac',
  pw:channel:command   method: 'screenshot',
  pw:channel:command   params: { type: 'png', fullPage: true }
  pw:channel:command } +53ms
  pw:protocol SEND ► {"method":"Runtime.callFunction","params":{"functionDeclaration":"(utilityScript, ...args) => utilityScript.evaluate(...args)","args":[{"objectId":"id-49"},{"value":true},{"value":true},{"value":"() => {\n            if (!document.body || !document.documentElement)\n                return null;\n            return {\n                width: Math.max(document.body.scrollWidth, document.documentElement.scrollWidth, document.body.offsetWidth, document.documentElement.offsetWidth, document.body.clientWidth, document.documentElement.clientWidth),\n                height: Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight),\n            };\n        }"},{"value":1},{"value":{"v":"undefined"}}],"returnByValue":true,"executionContextId":"id-41"},"id":166,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a"} +5ms
  pw:protocol ◀ RECV {"id":166,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a","result":{"result":{"value":{"o":[{"k":"width","v":1600},{"k":"height","v":1024}]}}}} +1ms
  pw:protocol SEND ► {"method":"Page.screenshot","params":{"mimeType":"image/png","clip":{"x":0,"y":0,"width":1600,"height":1024}},"id":167,"sessionId":"e9dae51f-27a3-054f-a8d6-24bc11e3900a"} +0ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions