Poltergeist Stripe checkout.js [英] Poltergeist Stripe checkout.js

查看:69
本文介绍了Poltergeist Stripe checkout.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Rails应用程序中测试Stripe checkout弹出窗口( http://www.stripe.com/checkout)。

I'm trying to test in my Rails app the Stripe checkout popup (http://www.stripe.com/checkout).

我正在使用Capybara +硒驱动器,并且一切正常。
加载页面时,checkout.js添加了一个iframe,我可以访问它

I was using Capybara + selenium-driver and everything worked well. When the page is loaded, the checkout.js adds an iframe, and I was able to access it

within_frame('stripe_checkout_app') do
 do something
end

现在,切换到Poltergeist,我收到此错误:

Now, switching to Poltergeist, I get this error:


失败/错误:internal_frame('stripe_checkout_app')做
Capybara :: Poltergeist :: FrameNotFound:
找不到框架'stripe_checkout_app'。

Failure/Error: within_frame('stripe_checkout_app') do Capybara::Poltergeist::FrameNotFound: The frame 'stripe_checkout_app' was not found.

如果我检查页面,则没有iframe。因此,我认为该脚本

and if I inspect the page, there's not iframe. So I think that this script

< script type = text / javascript src = https://checkout.stripe.com/当我使用Poltergeist运行测试时,不会加载checkout.js>< / script>

不会加载。

更新

我尝试使用Capybara-webkit运行测试,结果相同。

I tried to run the test with Capybara-webkit, with same result.

Failure/Error: Capybara.within_frame('stripe_checkout_app') do
 Capybara::Webkit::InvalidResponseError:
   Unable to locate frame.

我也试图等待半分钟!

I also tried to wait for half a minute! with

sleep 30

这些是我的网络模拟设置:

These are my webmock settings:

RSpec.configure { |config|
WebMock.disable_net_connect!(allow_localhost: true)
 }

更新2:

'stripe_checkout_app'是iframe的名称。

'stripe_checkout_app' is the name of the 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>


推荐答案

对于感兴趣的任何人,我都找到了一种方法来访问只需使用Poltergeist切换窗口方法即可使用iframe,而无需使用 within_frame。

For anybody interested, I found a way to access the iframe without using 'within_frame', just by using the Poltergeist switch window method.

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

For spanish people, I found the solution here: numerica latina.

这篇关于Poltergeist Stripe checkout.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆