-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathservice_spec.rb
More file actions
45 lines (35 loc) · 1.43 KB
/
service_spec.rb
File metadata and controls
45 lines (35 loc) · 1.43 KB
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
42
43
44
45
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Service' do
let(:file_name) { File.expand_path('driver.log') }
let(:driver_path) { ENV.fetch('CHROMEDRIVER_BIN', nil) }
let(:browser_path) { ENV.fetch('CHROME_BIN', nil) }
before { driver_finder }
after { FileUtils.rm_f(file_name) }
it 'has default service' do
service = Selenium::WebDriver::Service.chrome
@driver = Selenium::WebDriver.for :chrome, service: service
end
it 'specifies driver location' do
user_data_dir = Dir.mktmpdir('chrome-profile-')
options = Selenium::WebDriver::Options.chrome(binary: browser_path)
options.add_argument("--user-data-dir=#{user_data_dir}")
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
service = Selenium::WebDriver::Service.chrome
service.executable_path = driver_path
@driver = Selenium::WebDriver.for :chrome, service: service, options: options
end
it 'specifies driver port' do
service = Selenium::WebDriver::Service.chrome
service.port = 1234
@driver = Selenium::WebDriver.for :chrome, service: service
end
def driver_finder
options = Selenium::WebDriver::Options.chrome(browser_version: 'stable')
service = Selenium::WebDriver::Service.chrome
finder = Selenium::WebDriver::DriverFinder.new(options, service)
ENV['CHROMEDRIVER_BIN'] = finder.driver_path
ENV['CHROME_BIN'] = finder.browser_path
end
end