Class: SparklingWatir::App

Inherits:
Object
  • Object
show all
Includes:
Gestures
Defined in:
lib/sparkling_watir.rb

Overview

For driving a native application

Constant Summary

Constants included from Gestures

Gestures::VIEWPORT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gestures

#action, #double_tap, #long_press, #perform, #scroll, #swipe, #tap

Constructor Details

#initialize(opts) ⇒ App

Returns a new instance of App.



18
19
20
21
# File 'lib/sparkling_watir.rb', line 18

def initialize(opts)
  url = opts[:caps]['url']
  @driver = Appium::Core::Driver.for(opts).start_driver(server_url: url)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/sparkling_watir.rb', line 53

def method_missing(method_name, *arguments, &block)
  if driver.respond_to? method_name
    driver.send method_name, *arguments, &block
  else
    super
  end
end

Instance Attribute Details

#driverObject

Returns the value of attribute driver.



14
15
16
# File 'lib/sparkling_watir.rb', line 14

def driver
  @driver
end

Instance Method Details

#android?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/sparkling_watir.rb', line 45

def android?
  platform == 'Android'
end

#element(selector) ⇒ Object



29
30
31
# File 'lib/sparkling_watir.rb', line 29

def element(selector)
  Element.new(driver, selector)
end

#elements(selector) ⇒ Object



33
34
35
# File 'lib/sparkling_watir.rb', line 33

def elements(selector)
  ElementCollection.new(driver, selector)
end

#ios?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/sparkling_watir.rb', line 49

def ios?
  platform == 'iOS'
end

#platformObject



41
42
43
# File 'lib/sparkling_watir.rb', line 41

def platform
  capabilities[:platform_name]
end

#quitObject Also known as: close



23
24
25
# File 'lib/sparkling_watir.rb', line 23

def quit
  driver.quit
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/sparkling_watir.rb', line 61

def respond_to_missing?(method_name, include_private = false)
  driver.respond_to?(method_name) || super
end

#screenshotObject



37
38
39
# File 'lib/sparkling_watir.rb', line 37

def screenshot
  Screenshot.new driver
end