You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First time using this instead of any other JS drivers, so thanks for the framework and exciting!
I'm trying to write a test for a Stripe checkout.js page (subscribing to a plan) and get intermittent failures. I'm trying to use capybara matchers that wait for the page to change before asserting that things happen. I haven't tried with a chromedriver based setup yet, but I imagine it will work.
For the script below, a sleep will cause capybara to wait and the assertions work. If I try to use the content changing on the page (content or css) then it fails intermittently. It appears the page object is stale while the redirect is happening?
Any thoughts or recommendations?
require'rails_helper'RSpec.feature'Subscriptions'dolet(:user){create(:user)}backgrounddologin_user(user)endcontext'as a new customer'dobackgrounddovisitorganization_pathendscenario'I can subscribe',js: truedoclick_link'Subscribe Now'expectdowithin'form.new_pay_subscription'doselect'Freelancer Plan',from: 'Subscription Plan'fill_in'Name on Card',with: 'Johnny Appleseed'fill_stripe_elements(card: '4111 1111 1111 1111')# stripe elements for interacting with iframe contentsclick_link_or_button'Create Subscription'end# ----HERE----## If I simply sleep after the button is clicked, enough time is given for the# page to redirect and my assertions below pass.## If I am a "good" capybara dev and wait for visual or DOM changes to indicate my# operation has completed instead, I get failures. I have tried several with the same outcome.## WORKS, not ideal obviously and brittle# sleep 2 # all of the following will fail and raise an exception about being in the wrong world# they are not consistent about failing with this error. I'm assuming that the faster the operation# completes and the page moves one (without the sleep of course) that the failure occurrs. # expect(page).to have_no_css('form.new_pay_subscription')# expect(page).to_not have_css('form.new_pay_subscription')# expect(page).to have_current_path(after_registration_path)end.tochange{user.organization.subscriptions.count}.by(1)endend
The text was updated successfully, but these errors were encountered:
First time using this instead of any other JS drivers, so thanks for the framework and exciting!
I'm trying to write a test for a Stripe checkout.js page (subscribing to a plan) and get intermittent failures. I'm trying to use capybara matchers that wait for the page to change before asserting that things happen. I haven't tried with a
chromedriver
based setup yet, but I imagine it will work.For the script below, a
sleep
will cause capybara to wait and the assertions work. If I try to use the content changing on the page (content or css) then it fails intermittently. It appears thepage
object is stale while the redirect is happening?Any thoughts or recommendations?
The text was updated successfully, but these errors were encountered: