Skip to content

Commit

Permalink
feat: add reCAPTCHA Cypress command
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Kabo committed Dec 7, 2023
1 parent 31117f8 commit 7b4247b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ Cypress.Commands.add('iframeLoaded', { prevSubject: 'element' }, ($iframe) => {
});
});

Cypress.Commands.add('solveGoogleReCAPTCHA', () => {
cy.get('#recaptcha *> iframe').then(($iframe) => {
const $body = $iframe.contents().find('body');
cy.wrap($body)
.find('.recaptcha-checkbox-border')
.should('be.visible')
.click();
});
});

Cypress.Commands.add('resolve', (name, options = {}) => {
const getValue = () => {
// @ts-ignore
Expand Down
1 change: 1 addition & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ declare global {
resolve(name: string): Chainable<Element>;
getIframeBody(selector: string): Chainable<Element>;
findByText(text: string): Chainable<Element>;
solveGoogleReCAPTCHA(): Chainable<Element>;
}
}
}
Expand Down

0 comments on commit 7b4247b

Please sign in to comment.