Capybara cannot fill Stripe Checkout.js fields

2019-05-27 10:59发布

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?

1条回答
冷血范
2楼-- · 2019-05-27 11:57

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'); })
查看更多
登录 后发表回答