class AutomationHelpers::Drivers::V4::Options

{AutomationHelpers::Drivers::V4::Options}

The Options object that will be used to instantiate whatever driver you are configuring

Public Class Methods

for(browser) click to toggle source

@return [Selenium::Webdriver::Options]

Returns the Options payload relevant to the browser specified to be passed to the driver instantiation

# File lib/automation_helpers/drivers/v4/options.rb, line 19
def for(browser)
  initial_options(browser).tap { |opts| opts.headless! if headless? }
end

Private Class Methods

headless?() click to toggle source
# File lib/automation_helpers/drivers/v4/options.rb, line 45
def headless?
  ENV['HEADLESS'] == 'true'
end
initial_options(browser) click to toggle source
# File lib/automation_helpers/drivers/v4/options.rb, line 25
def initial_options(browser)
  case browser
  when :chrome;             then ::Selenium::WebDriver::Chrome::Options.new
  when :firefox;            then ::Selenium::WebDriver::Firefox::Options.new(log_level: 'trace')
  when :edge;               then ::Selenium::WebDriver::Edge::Options.new
  when :safari;             then ::Selenium::WebDriver::Safari::Options.new(automatic_inspection: true)
  when :internet_explorer;  then internet_explorer_options
  else {}
  end
end
internet_explorer_options() click to toggle source

Constantly fire mouseOver events on click actions (Should help mitigate flaky clicks)

# File lib/automation_helpers/drivers/v4/options.rb, line 37
def internet_explorer_options
  ::Selenium::WebDriver::IE::Options.new(persistent_hover: true).tap do |opts|
    # This can be removed once we migrate past Se4 proper (As the space version name is present there)
    AutomationHelpers.logger.info('Removing `browser_name` key from options payload.')
    opts.options.delete(:browser_name)
  end
end