Home > database >  How does testcafe decide an iframe has loaded?
How does testcafe decide an iframe has loaded?

Time:03-24

I'm currently on the latest package 1.18.4 and having issues switching to an iframe during test execution.

Each time t.switchToIframe() is called, the following error is displayed:

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

This happens even though i can clearly see the iframe has loaded, even placing a length wait of 60 seconds when landing on the page for testing purposes.

This rough code below should be runnable and reproduce the problem:

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();
  });

CodePudding user response:

In general, there are two steps to switch to iframe. The first step is getting a selector with an iframe, but if the selector doesn't exist, you will get another error. The next step is getting contentWindow with a native getter. The error probably occurs on this step, but I can't reproduce this case with your iframe example. Could you share a full test example that illustrates this error?

Also, you put the content of the iframe between the tags, but it doesn't work like this. You need to set the path to the document in the src attribute of the iframe.

  • Related