Last active
December 4, 2018 17:56
-
-
Save dmitry-zaets/6b90ee413eadfadbcd208b43a1aa433c to your computer and use it in GitHub Desktop.
Testing Stripe Element fields with Nigthwatch.js
This file contains hidden or 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
module.exports = { | |
'Create a paid listing': function(browser) { | |
browser | |
.init() | |
.waitForElementVisible('body', 1000) | |
// Code to navigate to payment form | |
// Stripe card | |
.waitForElementPresent('.e2e-card-number iframe', 10000) | |
.element('css selector', '.e2e-card-number iframe', el => { | |
browser | |
.frame(el.value) | |
.waitForElementPresent('input[name=cardnumber]', 1000) | |
.setValue('input[name=cardnumber]', '') | |
.keys(['4']).pause(100).keys(['2']).pause(100).keys(['4']).pause(100).keys(['2']).pause(500) | |
.keys(['4']).pause(100).keys(['2']).pause(100).keys(['4']).pause(100).keys(['2']).pause(500) | |
.keys(['4']).pause(100).keys(['2']).pause(100).keys(['4']).pause(100).keys(['2']).pause(500) | |
.keys(['4']).pause(100).keys(['2']).pause(100).keys(['4']).pause(100).keys(['2']) | |
.assert.value('input[name=cardnumber]', '4242 4242 4242 4242') | |
.frame(null); | |
}) | |
// Stripe expiration date | |
.waitForElementPresent('.e2e-card-expirity iframe', 10000) | |
.element('css selector', '.e2e-card-expirity iframe', el => { | |
browser | |
.frame(el.value) | |
.waitForElementPresent('input[name=exp-date]', 1000) | |
.setValue('input[name=exp-date]', '') | |
.keys(['1']).pause(100).keys(['1']).pause(100).keys(['2']).pause(100).keys(['0']) | |
.assert.value('input[name=exp-date]', '11 / 20') | |
.frame(null); | |
}) | |
// Stripe expiration cvc | |
.waitForElementPresent('.e2e-card-cvc iframe', 10000) | |
.element('css selector', '.e2e-card-cvc iframe', el => { | |
browser | |
.frame(el.value) | |
.waitForElementPresent('input[name=cvc]', 1000) | |
.setValue('input[name=cvc]', '') | |
.keys(['1']).pause(100).keys(['2']).pause(100).keys(['3']) | |
.assert.value('input[name=cvc]', '123') | |
.frame(null); | |
}) | |
.click('.e2e-pay') | |
// assert that the payment is done | |
.end(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment