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):
https://sites.google.com/a/chromium.org/chromedriver/ -
Run
bundle install -
Run RSpec or Spinach tests as normal
Notes:
- 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.
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_keyswith non-BMP characters. (bug report) -
Create helper to work around the more restrictive add_cookieimplementation -
Fix tests where accept_confirmis 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:
-
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 status_code: https://stackoverflow.com/questions/7908907/how-to-test-the-response-code-with-capybara-selenium -
https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/28861088: Selenium does not support response_headers -
https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/28877991: Selenium does not support network_traffic: https://stackoverflow.com/questions/12034013/is-there-any-way-to-log-http-requests-responses-using-selenium-webdriver-firefo/12036058#12036058
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)