Sé que, de acuerdo con las mejores prácticas de Cypress , se recomienda no probar aplicaciones de terceros que no estén bajo nuestro control, pero como futuro evaluador, estoy afirmando mi autoridad al hacerlo de todos modos.
Entonces, solo quería probar el procedimiento log in y la respuesta POST con el estado 200 para esta página en particular , así que escribí el siguiente caso de prueba aquí:
describe('Log in and Log out Tests', () => { it('Log in Test', () => { /// Go to 'https://bandcamp.com/' cy.visit('https://bandcamp.com/') /// Get the 'log in' element and click it cy.get("[class='log-in-link']").click() /// Assert the log in page is 'https://bandcamp.com/login' cy.url().should('include', '/login') /// Set up the API variable, in this case the url was '**/login_cb' cy.intercept('POST', '**/login_cb').as('POSTresponse') /// Get the 'Username/email' textbox and type the email then verifies such textbox contains the previous cy.get('[name="username-field"]').type('xxxx@outlook.com') .should('have.value', 'xxxx@outlook.com') /// Get the 'Password' textbox and type the password cy.get('[name="password-field"]').type('xyz') .should('have.value', 'xyz') /// Click the 'Log in' button cy.get('#loginform > div.buttons > button').click() /// Here comes the human tester that kills the reCaptcha manually IF NEEDED /// /// Now wait for the POSTresponse variable cy.wait('@POSTresponse') /// Print the value of POSTresponse variable as a JQuery object cy.get('@POSTresponse').then( XHR => { console.log(XHR) // Check that the status code is equal to 200 (success) expect(XHR.response.statusCode).to.equal(200) }) }) })La cuestión es que, al ejecutar la prueba automatizada anterior, dicha página a veces lanza un reCaptcha para resolverlo, a veces no, por lo que me gustaría saber si hay alguna forma de agregar una excepción if/else para tal evento donde la prueba literalmente espera hasta que el reCaptcha se resuelva manualmente (por mí), para luego ejecutar el resto del código.
Abajo
Aquí viene el probador humano que mata el reCaptcha manualmente SI ES NECESARIO
insertar
cy.intercept('POST' , 'https://www.google.com/recaptcha/*').as('googleCaptcha') cy.wait('@googleCaptcha').its('response.statusCode').should('eq', 200)