testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

Unable to switch iframe

Open rushby opened this issue 4 years ago • 14 comments

What is your Scenario?

I am attempting to switch to an iframe using TestCafe.

What is the Current behavior?

When attempting to switch to an iframe, TestCafe does not think that it has loaded and displays the following message:

"Content of the iframe in which the test is currently operating did not load."

What is the Expected behavior?

TestCafe successfully switches to the iframe

What is your public website URL? (or attach your complete example)

https://www.terrific.ie/dealer/bradys-of-castleknock/finance/45784/13295

Note this vehicle may not be available at some point

What is your TestCafe test code?

import { Selector, t } from "testcafe";

fixture(`Quick Test`);

test
 .page(`https://www.terrific.ie/dealer/bradys-of-castleknock/finance/45784/13295`)(
  `Quick Test`,
  async () => {
      await t
       .click(`.submit-outer`)
       .expect(Selector(`.car-summary-box`).visible)
       .ok()
       .expect(Selector(`.cw-finance-plugin.plugin-loaded`).visible)
       .ok()
       .switchToIframe(`.cw-finance-plugin.plugin-loaded`)
       .click(`.cw-checkmark`)
       .debug();
  });

Your complete configuration file

No response

Your complete test report

No response

Screenshots

No response

Steps to Reproduce

  1. Run the attached code

TestCafe version

1.18.4

Node.js version

v14.19.0

Command-line arguments

testcafe chrome

Browser name(s) and version(s)

Chrome latest

Platform(s) and version(s)

No response

Other

This has been reproduced by Aleksey as per this stackoverflow question:

https://stackoverflow.com/questions/71528890/how-does-testcafe-decide-an-iframe-has-loaded/71558047

rushby avatar Mar 23 '22 09:03 rushby

Hi @rushby,

Thank you for the example. I reproduced the issue. We will research it and will update this thread once we have any results.

For the team: we should wait 5000ms until switching to iframe.

Aleksey28 avatar Mar 23 '22 12:03 Aleksey28

Thanks @Aleksey28 - it would be appreciated if this could be fixed quickly (if it's a relatively easy change), currently we've got towards the end of development and discovered a key component in our "checkout" journey isn't interactable and blocking us from testing a complete user journey.

rushby avatar Mar 25 '22 10:03 rushby

I can't give you an estimate. Any personal estimate could be misleading, so we cannot say anything at the moment. Once we get any results, we will post them in this thread.

Aleksey28 avatar Mar 28 '22 07:03 Aleksey28

Is there any update on this issue? I am having the same issue after upgrading the Testcafe to 1.18.4

shorianita avatar Apr 18 '22 19:04 shorianita

No updates yet. Once we get any results, we will post them in this thread.

github-actions[bot] avatar Apr 20 '22 15:04 github-actions[bot]

Currently, we do not have a complete solution yet. The 5-second delay mentioned by @Aleksey28 is a workaround, we cannot use it in the production code. You can make your own TestCafe fork, try the workaround and see if it helps. I increased this issue's priority but I can't give you any estimates.

AndreyBelym avatar Apr 21 '22 05:04 AndreyBelym

Thanks @AndreyBelym would you be able to point us to the area in the code where this 5 second delay workaround can be added?

rushby avatar Apr 21 '22 08:04 rushby

Hi @rushby, Alexey meant that the delay is needed to reproduce the issue, not resolve it. Please accept our apologies for misleading you. I am currently researching this issue and will update this thread once I have results.

Artem-Babich avatar Apr 26 '22 12:04 Artem-Babich

Hi @rushby,

After additional research, we came to the conclusion that Hammerhead cannot correctly initialize the iframe element. However, it is not possible to determine the exact cause of this issue due to the fact that your application scripts are minified. I tried to debug your application code and dynamically change it in order to correctly initialize the iframe and the Angular application located in this iframe. However, I encountered issues with routing that I was not able to resolve. To continue debugging and resolve this issue, we need to research this application locally. Please create a simplified version of your application that illustrates the issue and share it with us.

Artem-Babich avatar May 04 '22 10:05 Artem-Babich

@Artem-Babich thank you for the response, unfortunately the iframe is a 3rd party and we have no access to their code. It's not ideal but we autofill the form and purely just want to submit it, which is where the switch to iframe is required.

Perhaps @shorianita has a sample app available.

rushby avatar May 04 '22 11:05 rushby

@Artem-Babich thank you for the response, unfortunately the iframe is a 3rd party and we have no access to their code. It's not ideal but we autofill the form and purely just want to submit it, which is where the switch to iframe is required.

Perhaps @shorianita has a sample app available.

@rushby - The iframe for my application is 3rd party and don't have access to their code.

shorianita avatar May 11 '22 20:05 shorianita

For some reason, the connection with the iframe is not established. Currently, it is not possible to determine the cause of the issue due to a large amount of minified code. If you have a better example, please share it. This will make it easier to determine the cause of the issue. As soon as we have any news, we will update the thread.

Artem-Babich avatar May 13 '22 08:05 Artem-Babich

We also have this issue, intermittently. In case it helps, try this test sample:

import {Selector} from "testcafe";

fixture`TestCafe Demo Test`
  .beforeEach(async t => {
    await t
    .maximizeWindow()
    .navigateTo("https://mailchimp.com/login")
      .expect(Selector("div").withAttribute("data-mc-el", "loginAnnouncementAnimation")
        .with({ visibilityCheck: true }).exists).ok()
      .typeText(Selector("#username"), "abc123") // Enter your username here
      .typeText(Selector("#password"), "abc123") // Enter your password here
      .click(Selector("button[value='log in']"));
  })

test('Create email campaign', async t => {
  await t.click(Selector("li a").withAttribute("href", "#/create-campaign"))
    .click(Selector("div[role = 'listitem']").withText("Email"))
    .click(Selector("a span").withExactText("Regular"))
    .typeText(Selector("input").withAttribute("name", "textValue"), "Test Campaign")
    .click(Selector("button").withText("Begin"))
    .switchToMainWindow();

  const loadingFrame = Selector("[class *= 'frame'] [class *= 'loading']");
  await loadingFrame();
  if (await loadingFrame.exists) {
    await t
      .expect(loadingFrame.classNames)
      .notMatch(/active/, "container loading frame active", {timeout: 60000})
      .switchToIframe(Selector("#fallback:not([title *='Loading'])").with({visibilityCheck: true, timeout: 30000}));
  }
  await t
    .expect(Selector("[data-dojo-attach-point='itemContent'] img").with({ visibilityCheck: true }).exists).ok({timeout: 20000})
    .click(Selector("button").withText("Design Email"))
    .click(Selector("button").withAttribute("data-dojo-attach-point", "selectInlineEditorButton"))
});

kacy-weakley avatar Jun 09 '22 15:06 kacy-weakley

Hi @kacy-weakley,

I just tested your code in the latest version of TestCafe and see that the test is completed correctly. Please try the latest version on your side. As for the original issue described in this ticket, unfortunately, we cannot continue our research until we have a simple project illustrating the issue without third-party libraries.

Artem-Babich avatar Sep 23 '22 16:09 Artem-Babich