ruby on rails -不安全的JavaScript试图用URL访问框架-警告出现在poltergeist,但不会

ruby on rails - Unsafe JavaScript attempt to access frame with URL - Warning arises with poltergeist, but not selenium-webdriver

本文关键字:警告 poltergeist 框架 URL 不安全 rails on JavaScript ruby 访问      更新时间:2023-09-26

我已经在我的Rails应用程序上运行Cucumber测试了一段时间,使用Selenium-Webdriver作为javascript驱动程序,并有稳定的结果。我试着切换到Poltergeist以便无头运行。

我的几个测试运行一个测试条纹事务,它触发一个javascript弹出。我有这样的步骤:

When(/^I wait to see "([^"]*)" in a Stripe popup$/) do |arg1|
  within_frame 'stripe_checkout_app' do
    wait_until do
      expect(page).to have_content(arg1)
    end
  end
end

当我使用selenium作为我的Capybara javascript驱动程序时,这些步骤运行得非常好,但是当我使用:poltergeist作为javascript驱动程序时,它们失败了。我得到这样的错误:

 Unsafe JavaScript attempt to access frame with URL http://127.0.0.1:64780/charges/1/edit from frame with URL https://checkout.stripe.com/v3/VguVZoYKogJUsO05PpIlfA.html?distinct_id=ad0ab5bb-c346-dac7-62dc-2a4a8e4dcf64. Domains, protocols and ports must match.

有谁知道为什么poltergeist会出现这种错误,而selenium-webdriver不会出现这种错误吗?

您可以通过禁用web安全- phantomjs_options =['——web-security=false'] -在您的poltergeist驱动程序注册中摆脱该消息。但是,您确定这是一个错误而不仅仅是一个警告吗?任何现代浏览器都会阻止来自不同域的帧之间的访问(并且出于非常真实的安全原因应该这样做)。