Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestCafe hangs when the test switches between windows after switching to iframe #6085

Closed
Dmitry-Ostashev opened this issue Mar 25, 2021 · 2 comments
Assignees
Labels
FREQUENCY: level 1 SYSTEM: window management TYPE: bug The described behavior is considered as wrong (bug).

Comments

@Dmitry-Ostashev
Copy link
Contributor

What is your Test Scenario?

Switch to another window after switching to iframe

What is the Current behavior?

The test is passed, but it cannot be finished. TestCafe hangs without terminating.

What is the Expected behavior?

The TestCafe process should be finished.

What is your web application and your TestCafe test code?

 fixture `New Fixture`  
    .page `https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe`;

test('Test', async t => {
    const documentation = await t.openWindow('http://devexpress.github.io/testcafe/documentation');

    await t
        .switchToParentWindow()
        .switchToIframe('iframe')
        .switchToWindow(documentation)
        .click('h1');
});

Steps to Reproduce:

Run the test. TestCafe will execute all the steps. However, it will not be finished automatically.

Your Environment details:

  • testcafe version: 1.13.0
  • node.js version: 12.19.0
  • command-line arguments: npx testcafe chrome test.js
  • browser name and version: Chrome 88
  • platform and version: Win 10
@Dmitry-Ostashev Dmitry-Ostashev added SYSTEM: window management TYPE: bug The described behavior is considered as wrong (bug). labels Mar 25, 2021
@thelazurite-cell
Copy link

thelazurite-cell commented Apr 1, 2021

Hi Dmitry,

I've come across something like this too while working within iframes. I think as a work around try creating a function to wrap around managing an iframe like in the example below. I think for some reason there is an issue when you aren't on the main window before the test completes or errors, it doesn't switch back to the main window which causes the test to hang

    public async withinIframe(i: TestController, iframe: Selector, code: () => Promise<void>): Promise<void> {
        let error: Error;

        await i.switchToIframe(iframe);

        try {
            await code().catch(res => error = res);
        } catch (e) {
            error = e;
        }
        await i.switchToMainWindow();

        if (error) {
            throw error;
        }
    }

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Apr 1, 2021
@viktoria2506
Copy link

Thank you for sharing this workaround. I believe it will be helpful to other users.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Apr 2, 2021
@AlexKamaev AlexKamaev self-assigned this Dec 15, 2021
AlexKamaev added a commit to AlexKamaev/testcafe that referenced this issue Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FREQUENCY: level 1 SYSTEM: window management TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

5 participants