-
Notifications
You must be signed in to change notification settings - Fork 433
/
capybara.rb
41 lines (36 loc) · 1.36 KB
/
capybara.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'capybara'
require 'capybara/apparition'
require 'capybara/dsl'
require 'socket'
Capybara.register_driver :selenium_chrome_headless do |app|
options = {
window_size: [1280, 1024],
js_errors: false,
headless: true,
ignore_https_errors: true,
w3c: false,
browser_options: { 'disable-gpu': true, 'no-sandbox': true }
}
Capybara::Apparition::Driver.new(app, options)
end
Capybara.default_driver = :selenium_chrome_headless
Capybara.default_max_wait_time = 6
Capybara.javascript_driver = :selenium_chrome_headless
Capybara.save_path = '/tmp/rspec_screens'
# Attempt to click the associated label element if a checkbox/radio button are non-visible (This is especially useful for Bootstrap custom controls)
Capybara.automatic_label_click = true
# Set hostname
begin
hostname = Addrinfo.getaddrinfo(Socket.gethostname, 443, nil, :STREAM).first.getnameinfo[0]
rescue SocketError
hostname = ''
end
ipaddress = Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? }.ip_address
hostname = ipaddress if hostname.empty?
Capybara.app_host = ENV.fetch('SMOKETEST_HOST', "https://#{hostname}")
RSpec.configure do |config|
config.include Capybara::DSL
config.before do
page.driver.add_headers('User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0')
end
end