Class: AutomationObject::Driver::AppiumAdapter::Driver
- Inherits:
-
Proxy::Proxy
- Object
- Proxy::Proxy
- AutomationObject::Driver::AppiumAdapter::Driver
- Includes:
- CommonSelenium::Driver
- Defined in:
- lib/automation_object/driver/appium_adapter/driver.rb
Overview
Driver proxy for Appium Conform Appium driver interface to what's expected of the Driver Port
Constant Summary
- DOCUMENT_COMPLETE_LOOPS =
5
- DOCUMENT_COMPLETE_SLEEP =
0.2
Instance Attribute Summary collapse
Instance Method Summary collapse
- #accept_prompt ⇒ void
-
#browser? ⇒ Boolean
Whether or not browser is being used.
-
#close ⇒ void
Close current window.
- #dismiss_prompt ⇒ void
-
#document_complete? ⇒ Boolean
Document is complete.
-
#exists?(selector_type, selector_path) ⇒ Boolean
Exists or not.
-
#find_element(selector_type, selector_path) ⇒ AutomationObject::Driver::Element
Element.
-
#find_elements(selector_type, selector_path) ⇒ Array<AutomationObject::Driver::Element>
Element.
-
#get(url) ⇒ void
Navigates current window to a given url.
-
#initialize(driver) ⇒ Driver
constructor
A new instance of Driver.
- #quit ⇒ void
-
#title ⇒ String
Get the title of the document.
-
#wait(timeout = nil) ⇒ void
Set timeout wait.
-
#window_handle ⇒ String
Get window handle override.
-
#window_handle=(handle_value) ⇒ void
Set window handle override.
-
#window_handles ⇒ Array<String>
Window Handles Override.
Methods included from CommonSelenium::Driver
#back, #execute_script, #forward, #inner_window_height, #refresh, #scroll_position
Methods inherited from Proxy::Proxy
Constructor Details
#initialize(driver) ⇒ Driver
Returns a new instance of Driver
25 26 27 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 25 def initialize(driver) @subject = driver end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class AutomationObject::Proxy::Proxy
Instance Attribute Details
#browser ⇒ Boolean
88 89 90 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 88 def browser @browser end |
Instance Method Details
#accept_prompt ⇒ void
This method returns an undefined value.
78 79 80 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 78 def accept_prompt @subject.alert_accept end |
#browser? ⇒ Boolean
Returns whether or not browser is being used
97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 97 def browser? # Now we need to check Appium's contexts to see if WEBVIEW is in available_contexts available_contexts = @subject.available_contexts available_contexts.each do |context| if context =~ /^WEBVIEW_\d+$/ self.browser = true break end end browser end |
#close ⇒ void
This method returns an undefined value.
Close current window
163 164 165 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 163 def close @subject.close end |
#dismiss_prompt ⇒ void
This method returns an undefined value.
83 84 85 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 83 def dismiss_prompt @subject.alert_dismiss end |
#document_complete? ⇒ Boolean
Returns document is complete
149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 149 def document_complete? return true unless browser? # Skip for non-browser Appium sessions # Loop through a few times to double check correctness DOCUMENT_COMPLETE_LOOPS.times do sleep(DOCUMENT_COMPLETE_SLEEP) return false unless @subject.execute_script('return document.readyState;') == 'complete' end true end |
#exists?(selector_type, selector_path) ⇒ Boolean
Returns exists or not
52 53 54 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 52 def exists?(selector_type, selector_path) @subject.exists { @subject.find_element(selector_type, selector_path) } end |
#find_element(selector_type, selector_path) ⇒ AutomationObject::Driver::Element
Returns element
59 60 61 62 63 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 59 def find_element(selector_type, selector_path) element = @subject.find_element(selector_type, selector_path) # Wrap element in the adapter interface AutomationObject::Driver::Element.new(Element.new(self, element)) end |
#find_elements(selector_type, selector_path) ⇒ Array<AutomationObject::Driver::Element>
Returns element
68 69 70 71 72 73 74 75 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 68 def find_elements(selector_type, selector_path) elements = @subject.find_elements(selector_type, selector_path) elements.map do |element| # Wrap element in the adapter interface AutomationObject::Driver::Element.new(Element.new(self, element)) end end |
#get(url) ⇒ void
This method returns an undefined value.
Navigates current window to a given url
32 33 34 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 32 def get(url) @subject.get(url) end |
#quit ⇒ void
This method returns an undefined value.
168 169 170 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 168 def quit @subject.driver_quit end |
#title ⇒ String
Get the title of the document
38 39 40 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 38 def title @subject.title end |
#wait(timeout = nil) ⇒ void
This method returns an undefined value.
Set timeout wait
45 46 47 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 45 def wait(timeout = nil) @subject.set_wait(timeout) end |
#window_handle ⇒ String
Get window handle override
129 130 131 132 133 134 135 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 129 def window_handle return @subject.current_context unless browser? return @subject.window_handle if @subject.device_is_android? @subject.current_context end |
#window_handle=(handle_value) ⇒ void
This method returns an undefined value.
Set window handle override
140 141 142 143 144 145 146 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 140 def window_handle=(handle_value) if @subject.device_is_android? @subject.switch_to.window(handle_value) else @subject.set_context(handle_value) end end |
#window_handles ⇒ Array<String>
Window Handles Override
112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/automation_object/driver/appium_adapter/driver.rb', line 112 def window_handles if @subject.device_is_android? && browser? window_handles = @subject.window_handles else return @subject.available_contexts unless browser? window_handles = [] @subject.available_contexts.each do |context| window_handles.push(context) if context =~ /^WEBVIEW_\d+$/ end end window_handles end |