Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 664
The Sheek Geek Avatar asked Oct 12 '11 15:10

The Sheek Geek


People also ask

What is ChromeOptions?

ChromeOptions is a new concept added in Selenium WebDriver starting from Selenium version 3.6. 0 which is used for customizing the ChromeDriver session. By default when selenium opens up any browser (Chrome browser or Firefox browser), it opens up without any extension or history or cookies, etc.


2 Answers

I don't think you can, at the moment. Having the same problem. It doesn't appear that in the current version of chrome, that disabling the popup blocker is a command line switch any more.

http://codesearch.google.com/codesearch#OAMlx_jo-ck/src/chrome/common/chrome_switches.cc&exact_package=chromium

like image 154
John Avatar answered Oct 04 '22 16:10

John


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

like image 25
hwjp Avatar answered Oct 04 '22 14:10

hwjp