Skip to content

Replace PhantomJS with Headless Chrome for GitLab Integration Tests

Stan Hu requested to merge sh-headless-chrome-support into master

This is a transition from Capybara's Poltergeist/PhantomJS driver to Selenium WebDriver /w Headless Chrome. Because of differences in driver support and behavior, and the transition to a more accurate and capable browser, this introduces several test failures that needed to be addressed.

To Test Locally:

  1. Install Google Chrome and the latest version of ChromeDriver (currently 2.33):
    https://sites.google.com/a/chromium.org/chromedriver/

  2. Run bundle install

  3. Run RSpec or Spinach tests as normal

Notes:

  • You can disable headless mode by using export CHROME_HEADLESS=false in your terminal before running RSpec and watch the browser in real time as tests are run.

Tasks:

  • Add Selenium and configure it within Capybara for RSpec and Spinach
  • Remove Poltergeist and PhantomJS dependencies
  • Await bug fix within ChromeDriver for send_keys (bug report - fixed in v2.31)
  • Create work-around for missing request/response introspection features (status_code, response_headers, network_traffic)
  • Create helper to work around missing support for send_keys with non-BMP characters. (bug report)
  • Create helper to work around the more restrictive add_cookie implementation
  • Fix tests where accept_confirm is needed to explicitly resolve modal javascript confirm dialogs
  • Fix instances of trigger('click'); which were used to work-around poor PhantomJS behavior
  • Fix tests which relied on hidden element behavior within PhantomJS
  • Get all remaining tests to pass
  • Create EE port and get all tests to pass there (gitlab-ee!3245)

Older Notes:

Errors:

Be sure to read https://makandracards.com/makandra/7617-change-how-capybara-sees-or-ignores-hidden-elements about how Chrome/Selenium behaves differently with hidden elements.

Closes #30876 (closed)

Edited by Stan Hu

Merge request reports