Reputation: 31
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
Any help is appreciated
Upvotes: 1
Views: 2517
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