Hidden submit button breaking cypress tests

I’m not sure whether this is a new change, but recently our Cypress automation tests started failing because of this command:

cy.get('button[type="submit"]').click();

This was due to there being two submit buttons present in the DOM. One of the buttons is hidden, but cypress still gets confused about which one to click.

The fix was to replace this line with an enter keypress, but I just thought I’d mention it.

cy.get('#password').type(`${password}{enter}`);

Hey there!

Thanks for sharing it with the rest of community! I’m gonna make it more visible to others and share the solution here and highlight it:

Solution

The fix was to replace this line with an enter keypress.

cy.get('#password').type(`${password}{enter}`);
1 Like

Thanks! We ran into this same issue and the solution fixed it for us. Just an additional note to do this for both Username and Password

1 Like

I ran into this today too. Thanks for the fix! Here’s what I had before:

cy.get('input[name=username]').type(username);
cy.get('input[name=password]').type(password, {log: false});
cy.get('button[type=submit]').first().click();

After:

cy.get('input[name=username]').type(username);
cy.get('input[name=password]').type(`${password}{enter}`, {log: false});
1 Like

Thanks @mraible and @zachary.willard for sharing all that!

hello! wondering from the Auth0 perspective why that hidden submit button exists? We are seeing this issue break our automation tests as well. Will try the fix but just wondering

1 Like

Any help from the Auth0 devs would be greatly appreciated!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.