class AutomationObject::Driver::AppiumAdapter::Driver
Driver
proxy for Appium Conform Appium driver interface to what's expected of the Driver
Port
Constants
- DOCUMENT_COMPLETE_LOOPS
- DOCUMENT_COMPLETE_SLEEP
Attributes
@return [Boolean]
Public Class Methods
@param driver [Appium::Driver] Appium Driver
# File lib/automation_object/driver/appium_adapter/driver.rb, line 25 def initialize(driver) @subject = driver end
Public Instance Methods
@return [void]
# File lib/automation_object/driver/appium_adapter/driver.rb, line 78 def accept_prompt @subject.alert_accept end
@return [Boolean] whether or not browser is being used
# 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 current window @return [void]
# File lib/automation_object/driver/appium_adapter/driver.rb, line 163 def close @subject.close end
@return [void]
# File lib/automation_object/driver/appium_adapter/driver.rb, line 83 def dismiss_prompt @subject.alert_dismiss end
@return [Boolean] document is complete
# 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
@param selector_type [Symbol] selector type (:css, :xpath, etc…) @param selector_path [String] path to element @return [Boolean] exists or not
# 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
@param selector_type [Symbol] selector type, :css, :xpath, etc… @param selector_path [String] path to element @return [AutomationObject::Driver::Element] element
# 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
@param selector_type [Symbol] selector type, :css, :xpath, etc… @param selector_path [String] path to element @return [Array<AutomationObject::Driver::Element>] element
# 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
Navigates current window to a given url @param url [String] navigate to the following url @return [void]
# File lib/automation_object/driver/appium_adapter/driver.rb, line 32 def get(url) @subject.get(url) end
@return [void]
# File lib/automation_object/driver/appium_adapter/driver.rb, line 168 def quit @subject.driver_quit end
Get the title of the document @return [String]
# File lib/automation_object/driver/appium_adapter/driver.rb, line 38 def title @subject.title end
Set timeout wait @param timeout [Integer] the timeout in seconds @return [void]
# File lib/automation_object/driver/appium_adapter/driver.rb, line 45 def wait(timeout = nil) @subject.set_wait(timeout) end
Get window handle override @return [String] current window handle
# 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
Set window handle override @param handle_value [String] window handle value @return [void]
# 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 Override @return [Array<String>] array of window handles
# 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