Srini
Srini

Reputation: 31

click on recaptcha cypress version 3.8.-

we have reCaptcha and i am trying run automated test using cypress veriosn 3.8.0 following is the code to click

         cy.wait(500);
    cy.get('#g-recaptcha *> iframe')
      .then($iframe => {
        const $body = $iframe.contents().find('body');
        cy.wrap($body)
          .find('.recaptcha-checkbox-border')
          .should('be.visible')
          .click();
      });

I found this over internet but still not working for me. it is throwing error that it cannot find enter image description here Any help is appreciated

Upvotes: 1

Views: 2517

Answers (1)

Danish Ejaz
Danish Ejaz

Reputation: 21

this should work for you

cy.get('iframe')
 .first()
 .its('0.contentDocument.body')
 .should('not.be.undefined')
 .and('not.be.empty')
 .then(cy.wrap)
 .find('#recaptcha-anchor')
 .should('be.visible')
 .click();

Upvotes: 1

Related Questions