How to hide your selenium browser window with "headless"
We don't use the headless gem. Tests can run with Chrome in headless mode without additional libraries.
Note: While the solution in this card should still work, we prefer another solution now: Hide your Selenium browser window with a VNC server.
If you would like to hide the annoying selenium browser window that always gets the focus and prevents you from working, you can use the. This note provides some instructions how you can get it to work with your cucumber acceptance tests using selenium webdriver as a capybara driver.
xvfbif it is not installed yet on your system.Copy
sudo apt-get install xvfb
headlessgem to your Gemfile.Copy
group :cucumber do ... gem 'headless' end
Go to your
features/support/env.rbfile and include the following snippet:Copy
This starts an
xvfbprocess, registers a hook to destroy the process on exit and starts and stops the headless mode if you are running a scenario
If you don't want a specific scenario to hide the selenium browser window, you can tag it with
Note: If you are using paralell_tests to run your tests in parallel you have to take care of several things to get selenium to work. Please have a look at the note on running your tests in parallel.