Commit 9516c929 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'feature/gb/qa/switch-to-headless-chrome-via-selenium-webdriver' into 'master'

Use headless Google Chrome browser in GitLab QA

Closes gitlab-qa#45 and gitlab-qa#48

See merge request !11680
parents 26bcef97 2c33ee9e
FROM ruby:2.3
LABEL maintainer "Grzegorz Bizon <grzegorz@gitlab.com>"
RUN sed -i "s/httpredir.debian.org/ftp.us.debian.org/" /etc/apt/sources.list && \
apt-get update && apt-get install -y --force-yes \
libqt5webkit5-dev qt5-qmake qt5-default build-essential xvfb git && \
apt-get clean
##
# Update APT sources and install some dependencies
#
RUN sed -i "s/httpredir.debian.org/ftp.us.debian.org/" /etc/apt/sources.list
RUN apt-get update && apt-get install -y wget git unzip xvfb
##
# At this point Google Chrome Beta is 59 - first version with headless support
#
RUN wget -q https://dl.google.com/linux/direct/google-chrome-beta_current_amd64.deb
RUN dpkg -i google-chrome-beta_current_amd64.deb; apt-get -fy install
##
# Install chromedriver to make it work with Selenium
#
RUN wget -q https://chromedriver.storage.googleapis.com/2.29/chromedriver_linux64.zip
RUN unzip chromedriver_linux64.zip -d /usr/local/bin
RUN apt-get clean
WORKDIR /home/qa
......
......@@ -2,6 +2,6 @@ source 'https://rubygems.org'
gem 'capybara', '~> 2.12.1'
gem 'capybara-screenshot', '~> 1.0.14'
gem 'capybara-webkit', '~> 1.12.0'
gem 'rake', '~> 12.0.0'
gem 'rspec', '~> 3.5'
gem 'selenium-webdriver', '~> 2.53'
......@@ -16,7 +16,10 @@ GEM
capybara-webkit (1.12.0)
capybara (>= 2.3.0, < 2.13.0)
json
childprocess (0.7.0)
ffi (~> 1.0, >= 1.0.11)
diff-lcs (1.3)
ffi (1.9.18)
json (2.0.3)
launchy (2.4.3)
addressable (~> 2.3)
......@@ -44,6 +47,12 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
rubyzip (1.2.1)
selenium-webdriver (2.53.4)
childprocess (~> 0.5)
rubyzip (~> 1.0)
websocket (~> 1.0)
websocket (1.2.4)
xpath (2.0.0)
nokogiri (~> 1.3)
......@@ -56,6 +65,7 @@ DEPENDENCIES
capybara-webkit (~> 1.12.0)
rake (~> 12.0.0)
rspec (~> 3.5)
selenium-webdriver (~> 2.53)
BUNDLED WITH
1.14.6
require 'rspec/core'
require 'capybara/rspec'
require 'capybara-webkit'
require 'capybara-screenshot/rspec'
require 'selenium-webdriver'
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/LineLength
......@@ -20,7 +20,6 @@ module QA
configure_rspec!
configure_capybara!
configure_webkit!
end
def configure_rspec!
......@@ -43,9 +42,9 @@ module QA
config.order = :random
Kernel.srand config.seed
config.before(:all) do
page.current_window.resize_to(1200, 1800)
end
# config.before(:all) do
# page.current_window.resize_to(1200, 1800)
# end
config.formatter = :documentation
config.color = true
......@@ -53,26 +52,28 @@ module QA
end
def configure_capybara!
Capybara.register_driver :chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
'chromeOptions' => {
'binary' => '/opt/google/chrome-beta/google-chrome-beta',
'args' => %w[headless no-sandbox disable-gpu]
}
)
Capybara::Selenium::Driver
.new(app, browser: :chrome, desired_capabilities: capabilities)
end
Capybara.configure do |config|
config.app_host = @address
config.default_driver = :webkit
config.javascript_driver = :webkit
config.default_driver = :chrome
config.javascript_driver = :chrome
config.default_max_wait_time = 4
# https://github.com/mattheworiordan/capybara-screenshot/issues/164
config.save_path = 'tmp'
end
end
def configure_webkit!
Capybara::Webkit.configure do |config|
config.allow_url(@address)
config.block_unknown_urls
end
rescue RuntimeError # rubocop:disable Lint/HandleExceptions
# TODO, Webkit is already configured, this make this
# configuration step idempotent, should be improved.
end
end
end
end
......@@ -12,7 +12,6 @@ RSpec.configure do |config|
config.shared_context_metadata_behavior = :apply_to_host_groups
config.disable_monkey_patching!
config.expose_dsl_globally = true
config.warnings = true
config.profile_examples = 10
config.order = :random
Kernel.srand config.seed
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment