Cypress reload the page when submitting a form without form submit on Wikipedia login page #24662
-
I'm using Cypress 10 because that is the version that works with the image snapshot plugin. And I'm trying to test Polish Wikipedia plugin. And have this code: Cypress.Commands.add('login', (pass) => {
cy.visit('/w/index.php?title=Specjalna:Zaloguj');
cy.get('#wpName1').type('Ciemny vector test');
cy.get('#wpPassword1').type(pass).type('{enter}');
//cy.get('#userloginForm form').submit();
});
describe('dark vector test', () => {
beforeEach('login', () => {
cy.login(Cypress.env('WIKI_PASSWORD'));
});
it('test discussion', () => {
cy.visit('/wiki/Dyskusja_wikipedysty:Ciemny_vector_test');
cy.dark_vector_wait();
cy.matchImageSnapshot('discussion');
});
it('test-page page', () => {
cy.visit('/wiki/Wikipedysta:Ciemny_vector_test/test-page');
cy.dark_vector_wait();
cy.matchImageSnapshot('test-page');
});
}); And the second test is failing because Cypress is automatically reloading the page without form submission. Got an error This is the screenshot of two tests, as you can see there are no submit but page reload still happing. I've just tested and the plugin doesn't change anything and got the same error on Cypress 11.0.1 After the second login, I got a weird element on Wikipedia some kind of accessibility keyboard icon What's weird is that it happens in Google Chrome but in Firefox it works fine. I was trying multiple things is there a way to detect if the page got redirected so I don't have to submit a form? My tests fail randomly. I thought that I fixed it by disabling the keyboard on Wikipedia but it shows again. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I've solved my issue with this code: Cypress.Commands.add('login', (pass) => {
cy.visit('/w/index.php?title=Specjalna:Zaloguj');
cy.get('#wpName1').type('Ciemny vector test');
cy.get('#wpPassword1').type(pass);
// Wikipedia sometimes redirects without submiting a form
cy.url().then(url => {
if (url.match(/Zaloguj/)) {
cy.get('#userloginForm form').submit();
}
});
}); I have no idea why Wikipedia is redirecting without submit but this solved the issue. |
Beta Was this translation helpful? Give feedback.
I've solved my issue with this code:
I have no idea why Wikipedia is redirecting without submit but this solved the issue.