ItsNotAndy
ItsNotAndy

Reputation: 573

Cypress test hangs at iframe

When I run this test everything seems to work fine until I try click the button in the iframe. I have no problem selecting from the dropdown, but when I get to the last step where I want to click the button, the test hangs after the iframe has been loaded. Also, is there a better way for me to load the iframe so that I dont have to get it every time ? Here is my command:

require("cypress-xpath");

Cypress.Commands.add("old_report_export", function () {
  cy.get('[id="isc_1A"]').type(Cypress.env("name"));
  cy.get('[id="isc_1E"]').type(Cypress.env("password"));
  cy.get('[id="isc_1Z"]').realClick();
  cy.frameLoaded('[id="isc_3N"]');
  cy.iframe('[id="isc_3N"]').contains("RETAINED").should("be.visible");

  //Navigate to dashboard
  cy.get('[name="isc_2Xicon"]').click();

  cy.get("#isc_3Qtable > tbody > tr:nth-child(1) > td.menuTitleField > div").click();
  cy.get("#isc_3Xtable > tbody > tr:nth-child(6) > td.menuTitleField").click();

  cy.wait(10000);


 cy.iframe('[id="isc_4H"]')
 .find('[id="report_filter_dealer"]').select(this.testdata.dealer);
 cy.iframe('[id="isc_4H"]')
 .find('[id="report_filter_brand"]').select("Ford Thailand");
 cy.iframe('[id="isc_4H"]')
 .find('[id="report_filter_from_date"]').select("June 2023");
  cy.iframe('[id="isc_4H"]')
 .find('[id="load_page"]').select("All Pages - Report");

 cy.iframe('[id="isc_4H]').find('[id="report-run-btn"]').realClick();
});

This is my test runner. It hangs there until cypress times outenter image description here

I have tried using 'get' instead of find and ive tried 'click()' instead of 'realClick' as well as 'click({force: true})' all with no success

Upvotes: 1

Views: 599

Answers (1)

ItsNotAndy
ItsNotAndy

Reputation: 573

Okey, so I have now found that this works when I use the xpath to click the button. Why does it not work when I use the ID ?

cy.iframe('[id="isc_4H"]').xpath('//*[@id="report-run-btn"]').realClick();

This seems to work fine, but I know using the xpath could become problematic..

Upvotes: 1

Related Questions