Google Chrome中的弹出式窗口阻止导致水豚/ Rspec测试出现问题 [英] Popup blocking in Google Chrome causing issues with Capybara/Rspec tests

查看:208
本文介绍了Google Chrome中的弹出式窗口阻止导致水豚/ Rspec测试出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <$ c我使用Capybara / RSpec编写了一些自动化测试,我选择/配置了驱动程序$ c> Capybara.register_driver:selenium_chrome do | app | 
Capybara :: Selenium :: Driver.new(app,:browser =>:chrome)
end

我正在测试我点击的按钮是否打开一个弹出窗口,并且窗口正在显示它应该显示的内容。问题是,当测试打开窗口时,Google Chrome弹出式窗口拦截器会阻止它,导致测试失败。禁用选项菜单中的阻止程序不起作用。此外,我担心,一旦我在服务器上运行它们会导致同样的问题。



是否有办法自动禁用弹出块测试?

解决方案

我们有一个非常类似的问题。像约翰说的那样,命令行开关不再起作用。我们尝试使用自定义配置文件,但它似乎被覆盖。



最后通过手动解决它使用禁用弹出窗口, WebDriver 本身:

  driver.get('chrome:// settings / advanced')
driver.find_element_by_id('privacyContentSettingsButton')。click()
driver.find_element_by_name('popups')。click()

我猜,这更像是用户会做什么; - )


I'm writing some automated tests using Capybara/RSpec, I choose/configure the driver by using this little bit of ruby:

Capybara.register_driver :selenium_chrome do |app|
  Capybara::Selenium::Driver.new(app, :browser => :chrome)
end

I'm testing whether or not a button I click is opening a popup window and that the window is displaying the content it should. The issue is that when the test opens the window, the Google Chrome popup blocker blocks it, causing the tests to fail. Disabling the blocker from the options menu does not work. Also, I'm afraid that once I run these on the server it will cause the same issue.

Is there a way to disable the popup block for the tests automatically?

解决方案

We had a very similar problem. Like John says, the command-line switch no longer works. We tried using a custom profile, but it seemed to be overwritten.

Eventually solved it by manually disabling popups using WebDriver itself:

driver.get('chrome://settings/advanced')
driver.find_element_by_id('privacyContentSettingsButton').click()
driver.find_element_by_name('popups').click()

Which, I guess, is more like what the user would do anyway ;-)

这篇关于Google Chrome中的弹出式窗口阻止导致水豚/ Rspec测试出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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