Unable to switch iframe
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
- 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
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.
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.
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.
Is there any update on this issue? I am having the same issue after upgrading the Testcafe to 1.18.4
No updates yet. Once we get any results, we will post them in this thread.
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.
Thanks @AndreyBelym would you be able to point us to the area in the code where this 5 second delay workaround can be added?
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.
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 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.
@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.
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.
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"))
});
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.