Ruby on rails Poltergeist Stripe checkout.js
我正在尝试在Rails应用程序中测试条带签出弹出窗口() 我使用的是Capybara+selenium驱动程序,一切正常。 加载页面时,checkout.js会添加一个iframe,我可以访问它Ruby on rails Poltergeist Stripe checkout.js,ruby-on-rails,capybara,stripe-payments,poltergeist,Ruby On Rails,Capybara,Stripe Payments,Poltergeist,我正在尝试在Rails应用程序中测试条带签出弹出窗口() 我使用的是Capybara+selenium驱动程序,一切正常。 加载页面时,checkout.js会添加一个iframe,我可以访问它 within_frame('stripe_checkout_app') do do something end 现在,切换到恶鬼,我得到这个错误: 失败/错误:在\u框架内(“条带\u签出\u应用程序”)执行 水豚::Poltergeist::FrameNotFound: 找不到框架“stripe\
within_frame('stripe_checkout_app') do
do something
end
现在,切换到恶鬼,我得到这个错误:
失败/错误:在\u框架内(“条带\u签出\u应用程序”)执行
水豚::Poltergeist::FrameNotFound:
找不到框架“stripe\u checkout\u app”
如果我检查页面,就没有iframe。所以我觉得这个剧本
在我使用Poltergeist运行测试时未加载
更新
我试着用水豚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\u checkout\u app”是iframe的名称
<iframe frameborder="0" allowtransparency="true" src="https://checkout.stripe.com/v3" name="stripe_checkout_app" class="stripe_checkout_app" style="z-index: 9999; display: none; background-color: transparent; border: 0px none transparent; overflow-x: hidden; overflow-y: auto; visibility: visible; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;"></iframe>
对于任何感兴趣的人,我找到了一种不用“in_frame”访问iframe的方法,只需使用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
对于西班牙人来说,我在这里找到了解决方案:。如果你对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
帕罗夫,我也有同样的问题(),但当我尝试你的解决方案时,我得到了以下错误:
未定义的方法“window\u handles”for#
-有什么想法吗?谢谢你能查一下你用的是哪一种妖怪吗?方法在主分支中。谢谢你,帕罗夫!你引导我走上正确的道路!当我bundle update
时,我使用poltergeist(1.0.3)获得,这看起来很旧。。。检查我的GEM文件显示我已经将水豚锁定在“~>1.1.2”上,这将Poltergeist限制在1.0.3。更新一切到最新的宝石(水豚2.3.0和恶鬼1.5.1)修复一切!