Home > Blockchain >  Two new urls but second one missing path variable in Cypress
Two new urls but second one missing path variable in Cypress

Time:10-05

Maybe a bit difficult to explain but I have the following issue. I have created a link and Cypress wants to click it, but it seems to click it twice. The second time the path variable is missing (the ID of an incident) and now it stores 'undefined' as incident ID, while the ID is '458868'

Does anyone why it calls this URL twice and why the second time the incident ID is missing in the URL?

The step definition is:

cy.get('.html-link').click({force:true});

Thanks!! enter image description here

CodePudding user response:

It's unlikely the .click() is happening twice. More likely the 2nd call to /incidents is just part of the page load, same as call to /incidents before the click.

To check it out, put in a long wait before clicking, see if the order of logging changes.

"it stores 'undefined' as incident ID" - please clarify where it's being stored - on the server, or in the test via an intercept?

If you are using an intercept, it's matcher needs to be more specific.

CodePudding user response:

I think i have solved the issue:

@Fody said to add a wait in the step.

cy.get('.html-link').wait(1000).click({force:true});

Although i'm not a fan of waits, in this case it seems to work. Thanks.

  • Related