We've moved discussions to Discord

Unable to find field "Name on card" that is not disabled

Matt Bjornson
I'm struggling to get my spec to pass when I'm processing payment.. Here's the part of my spec that is failing...

context "new users" do
    scenario "happy path" do
      visit root_path
      click_on "Sign Up"
      expect(page).to have_current_path pricing_path
      within('#Personal_month', match: :first) do
        click_on "Get Started"
      end
      expect(page).to have_current_path new_user_registration_path
      fill_in "Company Name",	with: "Disney"
      fill_in "Full name",	with: "Bob Iger"
      fill_in "Email",	with: "mike@disney.com"
      fill_in "Password",	with: "password"
      check "I accept the"
      select "Central America"
      click_on "Sign up"
            #expect(page).to have_text("Welcome! You have signed up successfully.")
            #expect(page).to have_content "Checkout"
      fill_stripe_elements(card: "4242 4242 4242 4242")
      fill_in "Name on card", with: "Bob Iger"
      expect(page).not_to have_text("Your card number is incomplete.")
      expect(page).to have_button("Subscribe")
      click_on "Subscribe"
      expect(page).not_to have_content("Your card number is invalid.")
      expect(page).to have_current_path user_root_path
      expect(page).to have_content "Thanks for subscribing!"
      expect(page).to have_content "My Dashboard"
    end
  end



The error message I'm getting is
1) Users new users happy path
     Failure/Error: fill_in "Name on card", with: "Bob Iger"

     Capybara::ElementNotFound:
       Unable to find field "Name on card" that is not disabled

     [Screenshot]: tmp/capybara/screenshots/failures_r_spec_example_groups_users_new_users_happy_path_887.png


     # ./spec/system/users_spec.rb:52:in `block (3 levels) in <top (required)>'
     # ./spec/system/support/better_rails_system_tests.rb:28:in `block (2 levels) in <main>'

I've attached the screenshot from capybara....

error.png 103 KB


So I'm getting an error on my form, that's not the card number in my spec. I suspect that is why this is failing ( am I wrong?).

Any recommendations?



Chris Oliver
Typo somewhere or didn't save your test file?
Matt Bjornson
Thanks for getting back to me  Chris Oliver ! That test seems to pass and fail intermittently. I believe it's failing due to the response coming back with the error message of "Your card number is invalid." What's weird about that is that the card number you see in the screenshot above is different than my test. I'm not sure how that happens...

The card number in my test: "4242 4242 4242 4242"
The card number on the screenshot: "4242 4242 4224 2424"

Any idea how this happens?
Notifications
You’re not receiving notifications from this thread.