Skip to content

Commit

Permalink
[rb] fix arguments passed into tests
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Aug 16, 2023
1 parent d9bd8e3 commit 34955d3
Showing 1 changed file with 15 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def initialize
@create_driver_error_count = 0

$LOAD_PATH.insert(0, root.join('bazel-bin/rb/lib').to_s) if File.exist?(root.join('bazel-bin/rb/lib'))
WebDriver.logger.ignore(%i[logger_info selenium_manager])
WebDriver.logger.ignore(%i[logger_info])
SeleniumManager.bin_path = root.join('bazel-bin/rb/bin').to_s if File.exist?(root.join('bazel-bin/rb/bin'))

@driver = ENV.fetch('WD_SPEC_DRIVER', 'chrome').tr('-', '_').to_sym
Expand Down Expand Up @@ -166,12 +166,12 @@ def create_driver!(listener: nil, **opts, &block)

private

def build_options(args: [], **opts)
def build_options(**opts)
options_method = "#{browser}_options".to_sym
if private_methods.include?(options_method)
send(options_method, args: args, **opts)
send(options_method, **opts)
else
WebDriver::Options.send(browser, args: args, **opts)
WebDriver::Options.send(browser, **opts)
end
end

Expand Down Expand Up @@ -226,37 +226,33 @@ def firefox_driver(service: nil, **opts)
end

def safari_driver(**opts)
service_opts = {}
service_opts[:args] = []
service_opts[:args] << '--diagnose' if WebDriver.logger.debug?
service_opts = WebDriver.logger.debug? ? {args: '--diagnose'} : {}
service = WebDriver::Service.safari(**service_opts)
WebDriver::Driver.for(:safari, service: service, **opts)
end

def safari_preview_driver(**opts)
service_opts = {}
service_opts[:args] = []
service_opts[:args] << '--diagnose' if WebDriver.logger.debug?
service_opts = WebDriver.logger.debug? ? {args: '--diagnose'} : {}
service = WebDriver::Service.safari(**service_opts)
WebDriver::Driver.for(:safari, service: service, **opts)
end

def chrome_options(**opts)
def chrome_options(args: [], **opts)
opts[:binary] ||= ENV['CHROME_BINARY'] if ENV.key?('CHROME_BINARY')
opts[:args] << '--headless=chrome' if ENV['HEADLESS']
WebDriver::Options.chrome(**opts)
args << '--headless=chrome' if ENV['HEADLESS']
WebDriver::Options.chrome(args: args, **opts)
end

def edge_options(**opts)
def edge_options(args: [], **opts)
opts[:binary] ||= ENV['EDGE_BINARY'] if ENV.key?('EDGE_BINARY')
opts[:args] << '--headless=chrome' if ENV['HEADLESS']
WebDriver::Options.edge(**opts)
args << '--headless=chrome' if ENV['HEADLESS']
WebDriver::Options.edge(args: args, **opts)
end

def firefox_options(**opts)
def firefox_options(args: [], **opts)
opts[:binary] ||= ENV['FIREFOX_BINARY'] if ENV.key?('FIREFOX_BINARY')
opts[:args] << '--headless' if ENV['HEADLESS']
WebDriver::Options.firefox(**opts)
args << '--headless' if ENV['HEADLESS']
WebDriver::Options.firefox(args: args, **opts)
end

def ie_options(**opts)
Expand Down

0 comments on commit 34955d3

Please sign in to comment.