picardo
picardo

Reputation: 24896

Capybara cannot fill Stripe Checkout.js fields

I am having a difficult time testing Stripe's Checkout.js product with Capybara. The problem is Stripe has some tricky client side validation that fools Capybara's javascript driver, so when I tell Capybara to fill in a field, like this:

fill_in "card_number", with: "4242424242424242"

Stripe field only fills up oly the first three digits then it automatically puts a space after those digits, and that breaks Capybara badly.

How can I fix this?

Upvotes: 2

Views: 672

Answers (1)

linojon
linojon

Reputation: 1082

I don't know exactly but when i get into these situations i consider dropping directly into the browsers javascript, such as (in this case assuming jquery is present)

page.execute_script(%Q{ $('input#itsId').val('424242424242424242'); })

Upvotes: 4

Related Questions