Capybara is unable to find the form fields from Stripe?

Viewed 1392

I´m learning Ruby on Rails and i´m working on an application that use stripe to create premium accounts. Also, i´m using Rspec and Capybara to do the integration tests.

require 'spec_helper'

feature "user upgrade account to a premium plan" do
 scenario "user upgrade account", :js => true do
  user = FactoryGirl.create :user
  visit new_user_session_path
  fill_in 'Email', :with => user.email
  fill_in 'Password', :with => user.password
  click_button 'Sign in'

  visit new_charge_path
  click_button "Pay with Card"

  fill_in 'Email', :with => 'persona@example.com'
  fill_in "Card number", :with => "4242424242424242"
  fill_in 'CVC', :with => '123'
  fill_in 'MM/YY', :with => '11/14'

  click_button 'Pay $5.00'

 end

I run the test and i get an error message that says:

 Failure/Error: fill_in "Card number", :with => "4242424242424242"
 Capybara::ElementNotFound:
   Unable to find field "Card number"

Anyone knows, what can be the problem? Thanks.

3 Answers

for capybara with stripe testing:

Capybara.within_frame 'stripe_checkout_app' do
  fill_in "Card number", :with => "4242424242424242"
  fill_in 'CVC', :with => '123'
  fill_in 'Expiry', :with => '11/22'

  click_button 'Pay $5.00'
end

edit the exipry date to a month and year of future always.

Related