Created
May 9, 2023 19:04
-
-
Save gzzsound/5fdbaa8b3aef873c1b05b9d3a7132ce8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in Cypress commands.js | |
Cypress.Commands.add('getStripeElement', (selector, value) => { | |
cy.get('iframe') | |
.should((iframe) => expect(iframe.contents().find(selector)).to.exist) | |
.then((iframe) => cy.wrap(iframe.contents().find(selector))) | |
.within((input) => { | |
cy.wrap(input).should('not.be.disabled').clear().type(value) | |
}) | |
}) | |
// in your test | |
cy.getStripeElement("#Field-numberInput", "4242424242424242"); | |
cy.getStripeElement("#Field-expiryInput", "1025"); | |
cy.getStripeElement("#Field-cvcInput", "123"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment