水豚无法从Stripe中找到表单字段? [英] Capybara is unable to find the form fields from Stripe?
本文介绍了水豚无法从Stripe中找到表单字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习Ruby on Rails,并且正在开发一个使用Stripe创建高级帐户的应用程序。另外,我正在使用Rspec和Capybara进行集成测试。
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.
推荐答案
根据您如何集成Stripe,它可能会在<$内部显示表单c $ c> iframe 。如果是这种情况,则需要使用 Capybara.within_frame
将操作定位到正确的帧:
Depending on how you're integrating Stripe, it might be rendering the form inside an iframe
. If that's the case, you'll need to use Capybara.within_frame
to target the actions to the correct frame:
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"
Capybara.within_frame 'stripe_checkout_app' do
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
end
这篇关于水豚无法从Stripe中找到表单字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文