google-chromewebdrivercapybarapopup-blocker

Popup blocking in Google Chrome causing issues with Capybara/Rspec tests


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?


Solution

  • 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 ;-)