我试着在我的Rails应用程序中测试Stripe弹出(http://www.stripe.com/checkout)。
我用的是凯巴拉+硒驱动器,一切都很好。加载页面时,checkout.js添加一个iframe,并且我能够访问它。
within_frame('stripe_checkout_app') do
do something
end现在,切换到Poltergeist,我得到了一个错误:
失败/错误: within_frame( 'stripe_checkout_app‘) do Capybara::Poltergeist::FrameNotFound:没有找到框架’stripe_checkout_app‘。
如果我看了这一页,就没有了。所以我觉得这个剧本
<script type="text/javascript" src="https://checkout.stripe.com/checkout.js"></script>
在使用Poltergeist运行测试时未加载。
更新
我试着用做测试,结果也一样。
Failure/Error: Capybara.within_frame('stripe_checkout_app') do
Capybara::Webkit::InvalidResponseError:
Unable to locate frame.我也试着等了半分钟!使用
sleep 30这些是我的网页模拟设置:
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>发布于 2014-03-21 13:07:54
对于任何感兴趣的人,我找到了一种方法来访问iframe,而无需使用“iframe_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对于西班牙人,我在这里找到了解决方案:numerica latina。
发布于 2016-01-09 10:15:15
如果您对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)
endhttps://stackoverflow.com/questions/22540453
复制相似问题