Class: Appium::Capybara::Driver
- Inherits:
-
Capybara::Selenium::Driver
- Object
- Capybara::Selenium::Driver
- Appium::Capybara::Driver
- 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
-
#accept_modal(type, options = {}, &blk) ⇒ Object
override type and options are passed but can be ignored.
-
#appium_driver ⇒ Object
new.
-
#browser ⇒ Object
override.
-
#browser_initialized? ⇒ Boolean
deprecated
Deprecated.
This method is being removed
-
#dismiss_modal(type, options = {}, &blk) ⇒ Object
override type and options are passed but can be ignored.
-
#find_css(selector) ⇒ Object
override.
-
#find_custom(finder, locator) ⇒ Object
new.
-
#find_xpath(selector) ⇒ Object
override.
-
#quit ⇒ Object
override.
-
#reset! ⇒ Object
override.
-
#rotate(opts) ⇒ Object
new Use :landscape or :portrait.
-
#save_screenshot(path, options = {}) ⇒ Object
override Capybara always passes an options param but appium_lib can’t do anything with it.
-
#scroll_down ⇒ Object
new.
-
#scroll_up ⇒ Object
new.
-
#swipe(opts) ⇒ Object
new.
Instance Method Details
#accept_modal(type, options = {}, &blk) ⇒ Object
override type and options are passed but can be ignored.
67 68 69 |
# File 'lib/appium_capybara/driver/appium/driver.rb', line 67 def accept_modal(type, = {}, &blk) appium_driver.alert_accept end |
#appium_driver ⇒ Object
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 browser unless @appium_driver @appium_driver end |
#browser ⇒ Object
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 28 29 30 31 32 33 34 35 |
# File 'lib/appium_capybara/driver/appium/driver.rb', line 20 def browser return @browser if @browser @appium_driver = Appium::Driver.new @options, false # browser is the standard selenium driver without any appium methods @browser = @appium_driver.start_driver main = Process.pid at_exit do # Store the exit status of the test run since it goes away after calling the at_exit proc... @exit_status = $ERROR_INFO.status if $ERROR_INFO.is_a?(SystemExit) quit if Process.pid == main exit @exit_status if @exit_status # Force exit with stored status end @browser end |
#browser_initialized? ⇒ Boolean
This method is being removed
55 56 57 |
# File 'lib/appium_capybara/driver/appium/driver.rb', line 55 def browser_initialized? !!@browser end |
#dismiss_modal(type, options = {}, &blk) ⇒ Object
override type and options are passed but can be ignored.
61 62 63 |
# File 'lib/appium_capybara/driver/appium/driver.rb', line 61 def dismiss_modal(type, = {}, &blk) appium_driver.alert_dismiss end |
#find_css(selector) ⇒ Object
override
43 44 45 |
# File 'lib/appium_capybara/driver/appium/driver.rb', line 43 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
105 106 107 |
# File 'lib/appium_capybara/driver/appium/driver.rb', line 105 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
38 39 40 |
# File 'lib/appium_capybara/driver/appium/driver.rb', line 38 def find_xpath(selector) appium_driver.find_elements(:xpath, selector).map { |node| Appium::Capybara::Node.new(self, node) } end |
#quit ⇒ Object
override
110 111 112 113 114 115 116 117 |
# File 'lib/appium_capybara/driver/appium/driver.rb', line 110 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
48 49 50 51 52 |
# File 'lib/appium_capybara/driver/appium/driver.rb', line 48 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
94 95 96 |
# File 'lib/appium_capybara/driver/appium/driver.rb', line 94 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.
100 101 102 |
# File 'lib/appium_capybara/driver/appium/driver.rb', line 100 def save_screenshot(path, = {}) appium_driver.screenshot path if @appium_driver end |
#scroll_down ⇒ Object
new
77 78 79 |
# File 'lib/appium_capybara/driver/appium/driver.rb', line 77 def scroll_down browser.execute_script('mobile: scroll', direction: 'down') end |
#scroll_up ⇒ Object
new
72 73 74 |
# File 'lib/appium_capybara/driver/appium/driver.rb', line 72 def scroll_up browser.execute_script('mobile: scroll', direction: 'up') end |
#swipe(opts) ⇒ Object
new
82 83 84 85 86 87 88 89 90 |
# File 'lib/appium_capybara/driver/appium/driver.rb', line 82 def swipe(opts) start_x = opts.fetch :start_x, 0 start_y = opts.fetch :start_y, 0 end_x = opts.fetch :end_x, 0 end_y = opts.fetch :end_y, 0 duration = opts.fetch :duration, 200 Appium::TouchAction.new(browser).swipe(start_x: start_x, start_y: start_y, end_x: end_x, end_y: end_y, duration: duration).perform end |