DevExpress / testcafe

A Node.js tool to automate end-to-end web testing.
https://testcafe.io
MIT License
9.82k stars 673 forks source link

Allow switching to parent iframe #5429

Closed tourdedave closed 3 years ago

tourdedave commented 4 years ago

What is your Test Scenario?

Walk into a nested frame, and then access the parent frame without knowing the explicit selector for it.

What is the Current behavior?

Getting an element not visible error.

What is the Expected behavior?

TestCafe should switch into the parent frame.

Reproducer

const assert = require('assert')
const {Selector} = require('testcafe')

fixture`Nested Frames`.page`https://applitools.github.io/demo/TestPages/FramesTestPage/`

test('walk nested frame tree', async driver => {
    await driver.switchToIframe('[name="frame1"]')
    const parentDocument = await Selector('html')()
    await driver.switchToIframe('[name="frame1-1"]')
    const frameDocument = await Selector('html')()
    await driver.switchToIframe(frameDocument.selector.parent(0))
})
 Nested Frames
 ✖ walk nested frame tree

   1) The element that matches the specified selector is not visible.

      Browser: Chrome 84.0.4147.125 / macOS 10.15.5

          6 |test('walk nested frame tree', async driver => {
          7 |    await driver.switchToIframe('[name="frame1"]')
          8 |    const parentDocument = await Selector('html')()
          9 |    await driver.switchToIframe('[name="frame1-1"]')
         10 |    const frameDocument = await Selector('html')()
       > 11 |    await driver.switchToIframe(frameDocument.selector.parent(0))
         12 |})
         13 |

Steps to Reproduce:

  1. Unzip the repro.zip file
  2. npm i
  3. npm t

Your Environment details:

miherlosev commented 4 years ago

Hi @tourdedave

At present, it possible to switch into the parent iframe window only using the following approach: switch to main window -> navigate to target iframe. I believe the switchToIframeParentWindow method can be useful for your case. I will mark this issue as enhancement.

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this issue in the future. If it still affects you or you have any additional information regarding it, please leave a comment and we will keep it open.

github-actions[bot] commented 3 years ago

We're closing this issue after a prolonged period of inactivity. If it still affects you, please add a comment to this issue with up-to-date information. Thank you.