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
Defined Under Namespace
Classes: Base, Chrome, Firefox
Constant Summary
collapse
- DRIVERS =
{
chrome: :chromedriver,
firefox: :geckodriver
}.freeze
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options) ⇒ Object
26
27
28
|
# File 'lib/aranha/selenium/driver_factory.rb', line 26
common_constructor :options do
self.options = options.with_indifferent_access.freeze
end
|
Instance Attribute Details
#options ⇒ ActiveSupport::HashWithIndifferentAccess
|
# File 'lib/aranha/selenium/driver_factory.rb', line 21
|
Class Method Details
.create_driver(options = {}) ⇒ Object
11
12
13
|
# File 'lib/aranha/selenium/driver_factory.rb', line 11
def create_driver(options = {})
new(options).create_driver
end
|
Instance Method Details
#create_driver ⇒ Object
30
31
32
|
# File 'lib/aranha/selenium/driver_factory.rb', line 30
def create_driver
driver_class.new(driver_options).build
end
|
#default_driver_name ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/aranha/selenium/driver_factory.rb', line 45
def default_driver_name
DRIVERS.each do |driver, executable|
return driver if ::Aranha::Selenium::Executables.send(executable).exist?
end
raise "No driver found (#{DRIVERS.value.join(', ')})"
end
|
#driver_class ⇒ Object
38
39
40
41
42
43
|
# File 'lib/aranha/selenium/driver_factory.rb', line 38
def driver_class
Aranha::Selenium::DriverFactory.const_get(driver_name.classify)
rescue NameError
raise "Unknown Aranha Selenium driver: \"#{driver_name}\" " \
"(Class \"Aranha::Selenium::DriverFactory::#{driver_name.classify}\" not found)"
end
|
#driver_name ⇒ Object
34
35
36
|
# File 'lib/aranha/selenium/driver_factory.rb', line 34
def driver_name
(options[:driver] || default_driver_name).to_s
end
|