Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AUT navigates to Cypress runner upon page navigation. #7545

Closed
csalazar1 opened this issue May 30, 2020 · 5 comments
Closed

AUT navigates to Cypress runner upon page navigation. #7545

csalazar1 opened this issue May 30, 2020 · 5 comments

Comments

@csalazar1
Copy link

csalazar1 commented May 30, 2020

Use Cypress version 4.5.0 to reproduce. Later versions are currently blocked by(#7518)

This simple tests consists of:

  • Logging in
  • Visiting specific page with a form
  • Filing out required fields and submitting

Upon submission of the form, a page redirect happens and a series of uncaught errors fire. However, when the form is cancelled, the page redirect still happens, but without the errors.

Here's the code for both scenarios. The one where the error happens by submitting the form, and the one where everything is ok when canceling the form

it('Example With Errors',() => {
    cy.request('POST', '/Auth/Login', { username: 'cydemoadmin', password: 'Test1@#$%' })
    cy.visit('/#/Settings/business-units/Add')
    cy.get('[type=submit]').should('be.visible')

    cy.get('[name=Name]').type('TestBU8') //Change value after one use. You can just increase number
    cy.get('[name=OfficialName]').type('TestBU8') //Change value after one use. You can just increase number
    cy.get('[name=Email]').type('asdf2sdfsdf@ggmaill.com')
    cy.get('[name=PhoneNumber]').type('8185556767')
    cy.get('[type=submit]').click()
  })

  it('Example Without Errors',() => {
    cy.request('POST', '/Auth/Login', { username: 'cydemoadmin', password: 'Test1@#$%' })
    cy.visit('/#/Settings/business-units/Add')
    cy.get('[type=submit]').should('be.visible')
    cy.get('.btn-link.muted').click()
  })

Here's the stack trace
exception
noException

There seems to be a weird URL mutation happening for the scenario where the exceptions happen

@jennifer-shehane
Copy link
Member

I can't recreate the issue as described. I don't see the uncaught errors or the AUT window traversing into Cypress as shown in the first screenshot.

Please make sure to include all code required. It looks like you have some after code running in your test suite - this may be important to recreate.

Screen Shot 2020-06-01 at 6 07 21 PM

Regardless this looks similar to the issue we have a potential fix available for starting in 4.6.0 as an experiment. Can you try setting this config option in your cypress.json or elsewhere as soon as you are able to upgrade:

{
	"experimentalSourceRewriting": true
}

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Jun 1, 2020
@csalazar1
Copy link
Author

csalazar1 commented Jun 1, 2020

@jennifer-shehane I think it's because you ran both tests. There's no after You just need to run only the it() with the error. If you run both it()'s it'll move on the second test before the first one has finished loading the page and therefore the errors.

Nevertheless, I tried "experimentalSourceRewriting": true on 4.7.0 and got a different error. The page was never able to launch so the test never reached it
2
1

Just make sure to it.only() the Example With Errors test and change values of TestBU{##} to some random name that hasn't been used like test43823. You should see the URL mutation happen in an after() even though there is none specified in the spec file

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Jun 2, 2020

Ok, I missed the part about the repro requiring you change the test selector value.

Yah, I see the experimentalSourceRewriting ends up having the test hang.

Repro

describe('tests', () => {
  it('test 1', () => {
    cy.request('POST', 'https://qa1-cypress.st.dev/Auth/Login', { username: 'cydemoadmin', password: 'Test1@#$%' })
    cy.visit('https://qa1-cypress.st.dev/#/Settings/business-units/Add')
    cy.get('[type=submit]', {timeout: 15000}).should('be.visible')
  
    cy.get('[name=Name]').type('test43824')
    cy.get('[name=OfficialName]').type('test43824')
    cy.get('[name=Email]').type('asdf2sdfsdf@ggmaill.com')
    cy.get('[name=PhoneNumber]').type('8185556767')
    cy.get('[type=submit]').click()
  })

  it('test 2', () => {
    cy.request('POST', 'https://qa1-cypress.st.dev/Auth/Login', { username: 'cydemoadmin', password: 'Test1@#$%' })
    cy.visit('https://qa1-cypress.st.dev/#/Settings/business-units/Add')
    cy.get('[type=submit]', { timeout: 15000 }).should('be.visible')

    cy.get('[name=Name]').type('test43825') //Changed value
    cy.get('[name=OfficialName]').type('test43825') //Changed value
    cy.get('[name=Email]').type('asdf2sdfsdf@ggmaill.com')
    cy.get('[name=PhoneNumber]').type('8185556767')
    cy.get('[type=submit]').click()
  })
})

@jennifer-shehane jennifer-shehane changed the title Uncaught TypeErrors On Form Submission AUT navigates to Cypress runner upon page navigation. Jun 2, 2020
@cypress-bot cypress-bot bot added stage: needs investigating Someone from Cypress needs to look at this and removed stage: needs information Not enough info to reproduce the issue labels Jun 2, 2020
@csalazar1
Copy link
Author

csalazar1 commented Jun 25, 2020

Update: as of 4.9.0, using
{ "experimentalSourceRewriting": true }
Will give the following error
1

Without
{ "experimentalSourceRewriting": true }

There's a new error that happens
2

Same steps to repro as above. Just make sure you it.only() the test with the steps leading the errors, or simply have one it()

@jennifer-shehane
Copy link
Member

This is no longer reproducible from the given repro.

Since this issue hasn't had activity in a while, we'll close the issue until we can confirm this is still happening. Please comment if there is new information to provide concerning the original issue and we'd be happy to reopen.

@jennifer-shehane jennifer-shehane removed the stage: needs investigating Someone from Cypress needs to look at this label Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants