Page load timeout after clicking login button in Cypress

143 views Asked by At

I'm new to Cypress and trying to write E2E test of logging in to application. My test looks like this:

describe('my_test', () => {
    it('login', () => {
        cy.visit(Cypress.env('my_app_url'))

        cy.url().should("contain", "/login.do")
        cy.get('input[name=loginUserName]').should('exist').type(Cypress.env('my_app_username'))
        cy.get('input[name=loginPassword]').should('exist').type(Cypress.env('my_app_password'))
        cy.get('#loginButton').should('exist').click()

        cy.url().should('include', "console")
        cy.get('#_mocaTaskflowFrame').should('exist')
        cy.getCookie('sessionId').should('exist')
    })
})

After clicking login button I can see in cypress' window that browser is loading main page of application like in successful login, but the URL does not change and after 60 seconds (I tried also increasing timeout) Cypress throws error that page did not fire its 'load' event. AFAIK clicking the login button causes POST request which returns sessionId and after that should happen redirect to new URL.

I don't see any problems with loading any part of application, all source files are properly downloaded.

Interesting fact is that when I try to submit form by submit() method the page simply refreshes and nothing happens.

I think the problem is that cypress tries to load response of POST login request as page, but after that should happen reload or redirect to the main page of application. I don't know how to tell cypress that it shouldn't load response as page and go to the next step.

Here's run trace of my test: cypress test run

Unfortunately I don't have any technical knowledge about application I'm testing. I know only that it is out of a box solution and it's written in java.

I tried intercepting requests (probably wrong way), submitting form or typing {enter} instead of clicking, assagning form to variable and operate on that. I tried running it with command 'open' in cypress browser and 'run' in console and both gives the same result. I tried increasing parameter pageLoadTimeout and command cy.pause().

0

There are 0 answers