我正在尝试在我的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 . 所以我认为这个脚本
<script type="text/javascript" src="https://checkout.stripe.com/checkout.js"></script>
我用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 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>
2 回答
对于任何感兴趣的人,我找到了一种方法来访问iframe而不使用'within_frame',只需使用Poltergeist切换窗口方法 .
对于西班牙人,我在这里找到了解决方案:numerica latina .
如果您对
phantomjs 1.9.7
有类似问题,那是因为SSL设置 . 您可以使用以下方法禁用检