Class: Unobtainium::Driver

Inherits:
Object
  • Object
show all
Defined in:
lib/unobtainium/driver.rb

Overview

Creating a Driver instance creates either an Appium or Selenium driver depending on the arguments, and delegates all else to the underlying implementation.

It’s possible to add more drivers, but Appium and Selenium are the main targets.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Driver

Initializer



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/unobtainium/driver.rb', line 36

def initialize(*args)
  # Sanitize options
  @label, @options = sanitize_options(*args)

  # Load drivers
  load_drivers

  # Determine the driver class, if any
  driver_klass = get_driver(@label)
  if not driver_klass
    raise LoadError, "No driver implementation matching #{@label} found, "\
      "aborting!"
  end

  # Perform precondition checks of the driver class
  driver_klass.ensure_preconditions(@label, @options)

  # Great, instanciate!
  @impl = driver_klass.create(@label, @options)
end

Instance Attribute Details

#implObject (readonly)

Public methods



32
33
34
# File 'lib/unobtainium/driver.rb', line 32

def impl
  @impl
end

#labelObject (readonly)

Public methods



32
33
34
# File 'lib/unobtainium/driver.rb', line 32

def label
  @label
end

#optionsObject (readonly)

Public methods



32
33
34
# File 'lib/unobtainium/driver.rb', line 32

def options
  @options
end

Class Method Details

.create(*args) ⇒ Object

Create a driver instance with the given arguments



25
26
27
# File 'lib/unobtainium/driver.rb', line 25

def create(*args)
  Driver.new(*args)
end