cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.01k stars 3.18k forks source link

Unable to visit outlook login page #26666

Closed Amplify367 closed 1 year ago

Amplify367 commented 1 year ago

Current behavior

Cypress browser test closes itself when clicking on sign in button

Desired behavior

No response

Test code to reproduce

cy.visit('https://outlook.live.com');

// Click the "Sign in" button
cy.contains('Sign in').click();

// Enter login credentials and submit form
cy.get('#i0116').type('username');
cy.get('#idSIButton9').click();
cy.get('#i0118').type('password');
cy.get('#idSIButton9').click();

Cypress Version

v12. 9.0

Node version

v12. 22.5

Operating System

macOS

Debug Logs

No response

Other

No response

nagash77 commented 1 year ago

Hi @Amplify367 , are you trying to login from your site using microsoft authentication? Have you read through our guides on using 3rd party auth?

Amplify367 commented 1 year ago

Hi @nagash77 , I have tried using it through cy.origin also and making experimentalModifyObstructiveThirdPartyCode:true, Now browser does not closes but i am getting error at cy.origin can you help me with the coding part? I want to login to outlook.

Amplify367 commented 1 year ago
cy.visit('https://outlook.live.com');

// Click the "Sign in" button
cy.contains('Sign in').click();
cy.origin(
    'login. live.com', 
{
      args: {
        username,
      },
    },
    ({ username }) => {
      cy.get('input[type="email"]').type(username, {
        log: false,
      })
      cy.get('input[type="submit"]').click()
    }
  )

If you can help it would be a great assist for me, getting error same domain.

Amplify367 commented 1 year ago

Hi @mschile , I am able to login but on visiting outlook page getting chunk load error

Amplify367 commented 1 year ago

@mschile @nagash77 Failed resource: https://res.cdn.office.net/owamail/20230421002.17/scripts/owa.ven.graphql.m.js Back Filled Errors: Unhandled Rejection: ChunkLoadError: Loading chunk 203918 failed. (error: https://res-h3.public.cdn.office.net/owamail/20230421002.17/scripts/owa.ven.graphql.m.js):undefined%7CUnhandled Rejection: ChunkLoadError: Loading chunk 203918 failed. (error: https://res-h3.public.cdn.office.net/owamail/20230421002.17/scripts/owa.ven.graphql.m.js):undefined%7CUnhandled Rejection: ChunkLoadError: Loading chunk 203918 failed. (error: https://res-h3.public.cdn.office.net/owamail/20230421002.17/scripts/owa.ven.graphql.m.js):undefined%7CUnhandled

Can you assist me here, "outlook mail home page not loading", able to automate login process failing at outlook home page with above errors Url at which it is failing:-https://outlook.live.com/mail/0

mschile commented 1 year ago

Hi @Amplify367 👋, I was able to reproduce your issue using the following test:

it('should load outlook', () => {
  cy.on('uncaught:exception', () => {
    return false
  })

  cy.origin('https://outlook.live.com/owa', () => {
    cy.visit('/')
    cy.contains('Sign in').click()
  })

  cy.origin('login.live.com', () => {
    cy.get('input[type="email"]').type('<username>', { log: false })
    cy.get('input[type="submit"]').click()
    cy.get('input[type="password"]').type('<password>', { log: false })
    cy.get('input[type="submit"]').click()
    cy.get('#idBtn_Back').click()
  })

  cy.origin('https://outlook.live.com', () => {
    cy.contains('Outlook', { timeout: 20000 })
  })
})

Looking at the console errors there appears to be an issue with sub-resource integrity failing which is causing the ChunkLoadError. A change to experimentalModifyObstructiveThirdPartyCode may be needed.

What is your use-case for testing Outlook? Typically, we don't recommend testing websites that are not in your control.

Amplify367 commented 1 year ago

Hey @mschile , thanks for responding! experimentalModifyObstructiveThirdPartyCode already set it to true, still facing the ChunkLoadError. Use case for outlook is that I have to read a particular email for my test flow using Outlook UI. It would a great help for me if you assist me to solve the ChunkLoadError issue. Thanks!

mschile commented 1 year ago

A change to experimentalModifyObstructiveThirdPartyCode may be needed

experimentalModifyObstructiveThirdPartyCode already set it to true, still facing the ChunkLoadError.

Sorry, I should've been clearer, I was saying that we (Cypress) would probably need to make changes to the experimentalModifyObstructiveThirdPartyCode functionality to support this workflow.

You could try using a cy.intercept to rewrite the subresource integrity:

cy.intercept('https://outlook.live.com/mail/0/**', (req) => {
  req.on('response', (res) => {
    res.body = res.body.replaceAll('s.integrity=a.sriHashes[i]', 's["stripped-integrity"]=a.sriHashes[i]')
  })
})