Class: Aranha::Selenium::DriverFactory
- Inherits:
-
Object
- Object
- Aranha::Selenium::DriverFactory
show all
- Defined in:
- lib/aranha/selenium/driver_factory.rb,
lib/aranha/selenium/driver_factory/base.rb,
lib/aranha/selenium/driver_factory/chrome.rb,
lib/aranha/selenium/driver_factory/firefox.rb,
lib/aranha/selenium/driver_factory/create_specified_driver.rb
Defined Under Namespace
Classes: Base, Chrome, CreateSpecifiedDriver, Firefox
Constant Summary
collapse
- DRIVERS =
%i[chrome firefox].freeze
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options) ⇒ Object
21
22
23
24
25
|
# File 'lib/aranha/selenium/driver_factory.rb', line 21
common_constructor :options do
self.options = options.with_indifferent_access
self.driver_name_from_options = options.delete(:driver)
self.options = ::Aranha::Selenium::DriverOptions.assert(options)
end
|
Instance Attribute Details
#driver_name_from_options ⇒ Object
Returns the value of attribute driver_name_from_options.
14
15
16
|
# File 'lib/aranha/selenium/driver_factory.rb', line 14
def driver_name_from_options
@driver_name_from_options
end
|
|
# File 'lib/aranha/selenium/driver_factory.rb', line 16
|
Class Method Details
.create_driver(options = {}) ⇒ Object
7
8
9
|
# File 'lib/aranha/selenium/driver_factory.rb', line 7
def create_driver(options = {})
new(options).create_driver
end
|
Instance Method Details
28
29
30
31
32
33
34
|
# File 'lib/aranha/selenium/driver_factory.rb', line 28
def create_driver
if driver_name_from_options.present?
create_specified_driver(driver_name_from_options, options)
else
create_unspecified_driver
end
end
|
37
38
39
40
41
42
43
44
45
|
# File 'lib/aranha/selenium/driver_factory.rb', line 37
def create_unspecified_driver
DRIVERS.each do |e|
return create_specific_driver(e, options)
rescue Selenium::WebDriver::Error::SessionNotCreatedError
end
raise "No driver available (Tried: #{DRIVERS.join(', ')})"
end
|