Poltergeist Stripe checkout.js
我正在尝试在我的Rails应用程序中测试Stripe checkout弹出窗口( http://www.stripe.com/checkout )。
我正在使用Capybara + selenium-driver,一切运转良好。 加载页面后,checkout.js会添加一个iframe,我可以访问它
within_frame('stripe_checkout_app') do do something end
现在,切换到Poltergeist,我收到此错误:
失败/错误:within_frame(’stripe_checkout_app’)执行Capybara :: Poltergeist :: FrameNotFound:找不到框架’stripe_checkout_app’。
如果我检查页面,就没有iframe。 所以我认为这个脚本
我用Poltergeist运行测试时没有加载。
更新
我尝试用Capybara-webkit运行测试,结果相同。
Failure/Error: Capybara.within_frame('stripe_checkout_app') do Capybara::Webkit::InvalidResponseError: Unable to locate frame.
我也试着等了半分钟! 同
sleep 30
这些是我的webmock设置:
RSpec.configure { |config| WebMock.disable_net_connect!(allow_localhost: true) }
更新2:
‘stripe_checkout_app’是iframe的名称。
对于任何感兴趣的人,我找到了一种方法来访问iframe而不使用’within_frame’,只需使用Poltergeist开关窗口方法。
stripe = page.driver.window_handles.last page.within_window stripe do fill_in "Name", :with => "Name" fill_in "Street", :with => "Street" fill_in "Postal", :with => 10000 fill_in "City", :with => "Berlin" click_button "Payment Info" end
对于西class牙人来说,我在这里找到了解决方案: numerica latina 。
如果您对phantomjs 1.9.7
有类似的问题,那是因为SSL设置。 您可以使用以下命令禁用检
Capybara.register_driver :poltergeist do |app| options = { phantomjs_options: ['--ssl-protocol=any', '--ignore-ssl-errors=yes'], inspector: false } Capybara::Poltergeist::Driver.new(app, options) end