Class: Unobtainium::Drivers::Selenium Private
- Inherits:
-
Object
- Object
- Unobtainium::Drivers::Selenium
- Extended by:
- Support::Utility
- Defined in:
- lib/unobtainium/drivers/selenium.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Driver implementation wrapping the selenium-webdriver gem.
Direct Known Subclasses
Constant Summary collapse
- LABELS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Recognized labels for matching the driver
{ firefox: [:ff,], internet_explorer: [:internetexplorer, :explorer, :ie,], safari: [], chrome: [], chromium: [], }.freeze
- CHROMIUM_EXECUTABLES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
When :chromium is selected, search for these executables. The resulting label will be :chrome, but with an executable path set in the options.
[ 'chromium-browser' ].freeze
Class Method Summary collapse
-
.create(label, options) ⇒ Object
private
Create and return a driver instance.
-
.ensure_preconditions(_, _) ⇒ Object
private
Ensure that the driver’s preconditions are fulfilled.
-
.matches?(label) ⇒ Boolean
private
Return true if the given label matches this driver implementation, false otherwise.
-
.resolve_options(label, options) ⇒ Object
private
Selenium really wants symbol keys for the options.
Methods included from Support::Utility
Class Method Details
.create(label, options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create and return a driver instance
85 86 87 88 89 90 |
# File 'lib/unobtainium/drivers/selenium.rb', line 85 def create(label, ) # :nocov: driver = ::Selenium::WebDriver.for(normalize_label(label), ) return driver # :nocov: end |
.ensure_preconditions(_, _) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Ensure that the driver’s preconditions are fulfilled.
50 51 52 53 54 55 56 |
# File 'lib/unobtainium/drivers/selenium.rb', line 50 def ensure_preconditions(_, _) require 'selenium-webdriver' rescue LoadError => err raise LoadError, "#{err.}: you need to add "\ "'selenium-webdriver' to your Gemfile to use this driver!", err.backtrace end |
.matches?(label) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return true if the given label matches this driver implementation, false otherwise.
44 45 46 |
# File 'lib/unobtainium/drivers/selenium.rb', line 44 def matches?(label) return nil != normalize_label(label) end |
.resolve_options(label, options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Selenium really wants symbol keys for the options
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/unobtainium/drivers/selenium.rb', line 60 def (label, ) # Normalize label and options normalized = normalize_label(label) = ::Collapsium::UberHash.new( || {}) # Merge 'caps' and 'desired_capabilities', letting the latter win [:desired_capabilities] = ::Collapsium::UberHash.new(['caps']) .recursive_merge([:caps]) .recursive_merge([:desired_capabilities]) .delete(:caps) .delete('caps') # Chromium is chrome, but with a different binary. Help with that. label, = supplement_chromium(normalized, ) # Selenium expects the first level keys to be symbols *only*, so # indifferent access from UberHash isn't good. We have to fix that. = () return label, end |