Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to slow down Capybara?

I have any problem with Capybara and Stripe. I write some test to check entering card numbers. Sometimes I have a broken test.

When I use chromedriver and look at him - I see, that capybara entered the card numbers very fast. And sometimes it creates errors.

For example - I often use number 4242 4242 4242 4242 - test card from Visa. Sometimes Capybara entered 4242 as 2442, 2244 or 4224. Of course, the test had broken.

Can you help me? I don't know how to resolve this problem. Maybe, I missed something in the documentation?

Update. Yes of course.

stripe_iframe = all("iframe[name=__privateStripeFrame4]").last
Capybara.within_frame stripe_iframe do
  fill_in "cardnumber", with: "4242424242424242"
  fill_in "exp-date", with: "1222"
  fill_in "cvc", with: "123"
  fill_in "postal", with: postal if postal
end
click_button "Start your free trial"
like image 854
Dmitrij Verenikin Avatar asked Feb 21 '19 11:02

Dmitrij Verenikin


1 Answers

I solved same issue by sending card number digits one by one.

card_number = '4242424242424242'
card_number.chars.each do |digit|
  find_field('cardnumber').send_keys(digit)
end
like image 87
iskvmk Avatar answered Oct 19 '22 06:10

iskvmk