Skip to content

Instantly share code, notes, and snippets.

@twalpole
Created August 14, 2019 16:16
Show Gist options
  • Save twalpole/ce436a537b2aedc0136eb6880c69a56c to your computer and use it in GitHub Desktop.
Save twalpole/ce436a537b2aedc0136eb6880c69a56c to your computer and use it in GitHub Desktop.
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'selenium-webdriver', '3.142.3'
gem 'webdrivers'
gem 'capybara', '3.28.0'
gem 'byebug'
end
require "capybara/dsl"
require 'byebug'
sess = Capybara::Session.new(:selenium_chrome)
sess.visit("https://stripe.com/docs/stripe-js/elements/quickstart")
sess.within_frame do # only one outer frame - no locator necessary
frame = sess.find('#card-element iframe')
sess.within_frame(frame) do
sess.fill_in('cardnumber', with: '4242' * 4)
sess.fill_in('exp-date', with: '1220')
sess.fill_in('cvc', with: '111')
sess.fill_in('postal', with: '92054')
sess.assert_selector(:field, 'cardnumber', with: '4242 4242 4242 4242')
sess.assert_selector(:field, 'exp-date', with: '12 / 20')
sess.assert_selector(:field, 'cvc', with: '111')
sess.assert_selector(:field, 'postal', with: '92054')
end
end
sleep 30 # delay to look at browser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment