0

I am using Cypress to run a test, I sent one email to the other then sign into the second email to see if the email was sent. Unfortunately though at the bottom of the below code the webpage in Cypress turns to blank. Any idea why and what I can do to fix it?

it('Send email', function () {
        cy.visit('https://login.yahoo.com/?.src=ym&pspid=159600001&activity=mail-direct&.lang=en-GB&.intl=uk&.done=https%3A%2F%2Fuk.mail.yahoo.com%2Fd');
        cy.get('.phone-no').type('//password here{enter}');
        cy.get('.password').type('//password here{enter}');
        Cypress.on('uncaught:exception', (err, runnable) => {
            return false
        })
        cy.get('.e_dRA').eq(0).click();
        Cypress.Commands.add('typeTab', (shiftKey, ctrlKey) => {
            cy.focused().trigger('keydown', {
                keyCode: 9,
                which: 9,
                shiftKey: shiftKey,
                ctrlKey: ctrlKey
            })
          })
        cy.get('.select-input').eq(1).type('//email here');
        cy.get('[role="textbox"]').type('Hi Second Email, the weather will be 10oc plus in the following destinations - Regards, First Email');
        cy.get('[title="Send this email"]').click();
        cy.get('[data-test-id="primary-btn"]').click();
        cy.get('._yb_1golm').click();
        cy.get('[data-soa="Sign out of all"]').click();
        cy.get('[data-redirect-params="pspid=[[pspid]]&activity=ybar-signin"]').click();
        cy.get('.pure-button').eq(1).click();
        //Crashes here

    });```

2 Answers2

0

Cypress has some limitations with social login as mentioned here git issue

If the requirement is to handle emails there are few alternatives like mailosaur which can help you. Also there is a npm plugin - cypress-social-logins which provides social login capabilities for some providers

GoushiRam
  • 87
  • 1
  • 5
-2

I have dealt a lot with webpages crashing when running Cypress tests. I do not know the specifics of your application, BUT I can give you some pointers. This entire block of code should have cy.wait(int) before fragile steps. I suspect that your application is crashing because Cypress is moving too fast. FYI cy.wait() is in milliseconds.

Here are some examples:

cy.get('.select-input').eq(1).type('//email here');
        cy.get('[role="textbox"]').type('Hi Second Email, the weather will be 10oc plus in the following destinations - Regards, First Email');
        cy.get('[title="Send this email"]').click();
        cy.get('[data-test-id="primary-btn"]').click();
        cy.get('._yb_1golm').click();
        cy.wait(300)
        cy.get('[data-soa="Sign out of all"]').click();
        cy.wait(300)
        cy.get('[data-redirect-params="pspid=[[pspid]]&activity=ybar-signin"]').click();
        cy.wait(300)
        cy.get('.pure-button').eq(1).click();

You can adjust these to different values. Let me know how it goes!

eaglehuntt
  • 53
  • 6
  • Better than waiting an arbitrary amount of time, you can spy and wait on request sent by your app. – jjhelguero Feb 14 '23 at 17:06
  • 1
    Actually it's a better approach to analyze what will be the recquirement to move on the test and assert over it, `should('be.visible')`, `should('be.enabled')` and `should('have.value')` in most cases can be used to avoid the static wait (at least in the experience I had with my application). – Leomelzer Feb 14 '23 at 18:02