Class: Appium::Capybara::Driver

Inherits:
Capybara::Selenium::Driver
  • Object
show all
Defined in:
lib/appium_capybara/driver/appium/driver.rb

Overview

methods in this class either override selenium driver methods or they’re new and specific to appium.

Instance Method Summary collapse

Instance Method Details

#accept_alertObject

new



57
58
59
# File 'lib/appium_capybara/driver/appium/driver.rb', line 57

def accept_alert
  appium_driver.alert_accept
end

#appium_driverObject

new

starts new driver



9
10
11
12
13
14
# File 'lib/appium_capybara/driver/appium/driver.rb', line 9

def appium_driver
  # must use self to reference the 'browser' method
  self.browser unless @appium_driver

  @appium_driver
end

#browserObject

override

Creates and starts a new appium driver. To access the browser without creating one use @browser



20
21
22
23
24
25
26
27
# File 'lib/appium_capybara/driver/appium/driver.rb', line 20

def browser
  unless @browser
    @appium_driver = Appium::Driver.new @options
    # browser is the standard selenium driver without any appium methods
    @browser = @appium_driver.start_driver
  end
  @browser
end

#browser_initialized?Boolean

new

Returns:

  • (Boolean)


47
48
49
# File 'lib/appium_capybara/driver/appium/driver.rb', line 47

def browser_initialized?
  !! @browser
end

#dismiss_alertObject

new



52
53
54
# File 'lib/appium_capybara/driver/appium/driver.rb', line 52

def dismiss_alert
  appium_driver.alert_dismiss
end

#find_css(selector) ⇒ Object

override



35
36
37
# File 'lib/appium_capybara/driver/appium/driver.rb', line 35

def find_css(selector)
  appium_driver.find_elements(:css, selector).map { |node| Appium::Capybara::Node.new(self, node) }
end

#find_custom(finder, locator) ⇒ Object

new



84
85
86
# File 'lib/appium_capybara/driver/appium/driver.rb', line 84

def find_custom(finder, locator)
  appium_driver.find_elements(finder, locator).map { |node| Appium::Capybara::Node.new(self, node) }
end

#find_xpath(selector) ⇒ Object

override



30
31
32
# File 'lib/appium_capybara/driver/appium/driver.rb', line 30

def find_xpath(selector)
  appium_driver.find_elements(:xpath, selector).map { |node| Appium::Capybara::Node.new(self, node) }
end

#quitObject

override



89
90
91
92
93
94
95
96
# File 'lib/appium_capybara/driver/appium/driver.rb', line 89

def quit
  @appium_driver.driver_quit if @browser || @appium_driver
rescue Errno::ECONNREFUSED
  # Browser must have already gone
ensure
  @browser = nil
  @appium_driver = nil
end

#reset!Object

override



40
41
42
43
44
# File 'lib/appium_capybara/driver/appium/driver.rb', line 40

def reset!
  # invoking the browser method after the browser has closed will cause it to relaunch
  # use @appium_driver to avoid the relaunch.
  @appium_driver.reset if @appium_driver
end

#rotate(opts) ⇒ Object

new Use :landscape or :portrait



73
74
75
# File 'lib/appium_capybara/driver/appium/driver.rb', line 73

def rotate(opts)
  browser.rotate opts
end

#save_screenshot(path, options = {}) ⇒ Object

override Capybara always passes an options param but appium_lib can’t do anything with it.



79
80
81
# File 'lib/appium_capybara/driver/appium/driver.rb', line 79

def save_screenshot(path, options = {})
  appium_driver.screenshot path
end

#scroll_downObject

new



67
68
69
# File 'lib/appium_capybara/driver/appium/driver.rb', line 67

def scroll_down
  browser.execute_script("mobile: scroll", direction: "down")
end

#scroll_upObject

new



62
63
64
# File 'lib/appium_capybara/driver/appium/driver.rb', line 62

def scroll_up
  browser.execute_script("mobile: scroll", direction: "up")
end