0
votes

I am attempting to integrate Stripe into a web app I'm building. However, I ran into a niggling problem when I tried to test a "Pay with Card" button. Whatever I seemed to do, rspec would throw up an ElementNotFound error.

After some searching I discovered this was because the default driver, rack_test, does not support Javascript. I then referred to some documentation: https://github.com/jnicklas/capybara#drivers and added :js => true to one of my RSpec scenarios, as well as the selenium-webdriver gem to my gemfile.

However, this has introduced another set of problems. Now whenever I run the test, I'm told that I'm using an invalid username/password combination, and I can't progress to the next part of the test to see whether or not I can click the damn button! Selenium seems to be not recognizing and/or invalidating my user factory.

Throws up hands.

Any help would be appreciated.

spec/features/user_upgrade_premium_spec.rb:

require 'rails_helper'

describe "Upgrade from Standard to Premium Plan" do
    before do
     @user = create(:user)
     visit root_path
     click_link "Sign In"
     fill_in 'Email', with: @user.email
     fill_in 'Password', with: @user.password
     click_button "Sign In"
     expect(page).to have_content "Signed in successfully."
  end

  scenario "Successfully", :js => true do
    click_link "My Account"
    click_link "Upgrade Account"

    click_button "Pay with Card"
 end
end  

spec/factories/user.rb

FactoryGirl.define do
  factory :user do
    name "User One"
    sequence(:email, 100) { |n| "person#{n}@example.com" }
    password "helloworld"
    password_confirmation "helloworld"
    confirmed_at Time.now
  end
end
1
are you using Page Object pattern? - Prashanth Sams
replace describe "Upgrade from Standard to Premium Plan" do with RSpec.describe "Upgrade from Standard to Premium Plan" do - Prashanth Sams

1 Answers

0
votes

Try script_timeout under Timeouts category such as implicit_wait and page_load; declare it globally and lets see how it works in our case!!

@driver.manage.timeouts.script_timeout = 15