How to verify gmail messages from UI without using...
# i-need-help
q
I have tried below code describe('Gmail Messages', () => { it('should read the subject lines of the messages', () => { cy.visit('https://mail.google.com%27/) // Assuming the email input field has an ID of 'identifierId' cy.get('input[type="email"]').type('your-email@gmail.com') // Assuming the 'Next' button has an ID of 'identifierNext' cy.get('#identifierNext').click() // Assuming the password input field has an ID of 'password' cy.get('input[type="password"]').type('your-password') // Assuming the 'Next' button has an ID of 'passwordNext' cy.get('#passwordNext').click() // Wait for the list of messages to load cy.get('.UI tr.zA').should('be.visible') // Extract the subject lines of the messages cy.get('.UI tr.zA .bog span.bqe') .invoke('text') .then(subjects => { // Perform assertions or further actions with the subject lines console.log(subjects) }) }) })
f
This is for multiple reasons are bad idea ^^' Never login using cypress into third party websites you do not control. Google can detect machine access and will try to block it. Generally speaking using cypress on websites you do not have sources access is considered bad practice. For mails i recommend either https://www.cypress.io/blog/2021/05/11/testing-html-emails-using-cypress/ or stubbing or if you use e.g external services like mailgun they offer an API endpoint to query mails and their subject lines
g