Replace PhantomJS with Headless Chrome for GitLab Integration Tests
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:
Install Google Chrome and the latest version of ChromeDriver (currently 2.33):
Run RSpec or Spinach tests as normal
- You can disable headless mode by using
export CHROME_HEADLESS=falsein your terminal before running RSpec and watch the browser in real time as tests are run.
- 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 (
Create helper to work around missing support for
send_keyswith non-BMP characters. (bug report)
Create helper to work around the more restrictive
Fix tests where
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)
unknown error: an X display is required for keycode conversions, consider using Xvfb(e.g. https://gitlab.com/gitlab-org/gitlab-ce/builds/18894684).
Bug report: https://bugs.chromium.org/p/chromedriver/issues/detail?id=1772. Some users mention compiling with
use_ozoneon Chrome and ChromeDriver solves this problem.
Alternatives: Use xvfb (https://github.com/Automattic/wp-e2e-tests/issues/515#issuecomment-301165065)
https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/27344249: Selenium does not support
https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/28861088: Selenium does not support
https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/28877991: Selenium does not support
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)