Class: Mobile
- Includes:
- Appium
- Defined in:
- lib/platform/mobile/mobile.rb
Overview
Mobile adds to or modifies a Platform with Mobile-specific functionality
Instance Attribute Summary
Attributes inherited from Platform
#id, #keys, #remotes, #roi, #screens
Instance Method Summary collapse
-
#android? ⇒ Boolean
Public: Checks if the device is Android.
-
#init?(args = {}) ⇒ Boolean
Public: Initializes a Mobile device.
-
#initialize(*args) ⇒ Mobile
constructor
Public: Initializes a Mobile device.
-
#ios? ⇒ Boolean
Public: Checks if the device is iOS.
-
#is_phone? ⇒ Boolean
Public: Checks if the device is a phone.
-
#is_tablet? ⇒ Boolean
Public: Checks if the device is a tablet.
-
#password ⇒ Object
Public: Gets the device password.
-
#software_version ⇒ Object
Public: Gets the device software version.
-
#username ⇒ Object
Public: Gets the device username.
Methods included from Appium
#double_click?, #flick?, #home?, #long_press?, #orientation, #orientation=, #power?, #rotate_landscape?, #rotate_portrait?, #rotation, #rotation=, #scroll?, #set_landscape?, #set_portrait?, #start_session?, #swipe?, #tap?
Methods included from Selenium
#back?, #element, #element?, #elements, #elements?, #time_to_element, #time_to_elements, #type?
Methods inherited from Platform
#alt_parental_controls_pin, #app_version, #audio_level, #audio_level_left, #audio_level_right, #audio_present?, #capture_audio, #capture_frames, #capture_screen, #device_type_is?, #device_type_not?, #entitlements, #has_power?, #height, #high_def?, #ip_address, #is_generic?, #lock, #mac_address, #model, #name, #parental_controls_pin, #platform, #power_cycle, #power_off, #power_on, #power_on?, #press_key, #record_audio, #record_video, #remote_type=, #remote_type_is?, #reset_video, #resolution, #save_last_screen_captured, #slot, #snmp_get, #snmp_set, #stop_audio, #stop_video, #upload_screenshot, #width
Constructor Details
#initialize(*args) ⇒ Mobile
Public: Initializes a Mobile device.
12 13 14 15 16 |
# File 'lib/platform/mobile/mobile.rb', line 12 def initialize(*args) super(*args) @screens = MobileScreens.new(self) @roi = MobileRois.new(self) end |
Instance Method Details
#android? ⇒ Boolean
Public: Checks if the device is Android.
Returns a Boolean true if the device is Android, otherwise false.
63 64 65 |
# File 'lib/platform/mobile/mobile.rb', line 63 def android? false end |
#init?(args = {}) ⇒ Boolean
Public: Initializes a Mobile device.
new_session - Boolean indicating whether to establish a new session (default: true). software_version - String version of app to install (default: nil).
If default, value of :software_version: from configuration will be used.
software_url - String URL to software network location (default: nil).
By default, it is assumed that software is stored locally.
install_software - Boolean indicating whether to install provided software version (default: true). timeout - Integer total milliseconds to allow before timing out (default: 120.sec). app_package - String mobile app package to use (default: nil).
By default, app package will be chosen based on mobile platform.
app_activity - String mobile app activity to use (default: nil).
By default, app activity will be chosen based on mobile platform.
bundle_id - String mobile bundle id to use (default: nil).
By default, bundle id will be chosen based on mobile platform.
sleep_time - Integer total milliseconds to sleep after establishing the session (default: 0).
Returns a Boolean true if the device was initialized, otherwise false.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/platform/mobile/mobile.rb', line 85 def init?(args={}) super() do logger.info('Starting session') args[:software_version] ||= software_version args[:new_session] = args.fetch(:new_session, true) args[:timeout] ||= 120.sec args[:sleep_time] ||= 0 start_time = Time.now while ((Time.now - start_time) * 1000) <= args[:timeout] return true if start_session?(args) logger.info('Failed to init! Retrying...') sleep(1.sec) end false end end |
#ios? ⇒ Boolean
Public: Checks if the device is iOS.
Returns a Boolean true if the device is iOS, otherwise false.
56 57 58 |
# File 'lib/platform/mobile/mobile.rb', line 56 def ios? false end |
#is_phone? ⇒ Boolean
Public: Checks if the device is a phone.
Returns a Boolean true if the device is a phone, otherwise false.
49 50 51 |
# File 'lib/platform/mobile/mobile.rb', line 49 def is_phone? false end |
#is_tablet? ⇒ Boolean
Public: Checks if the device is a tablet.
Returns a Boolean true if the device is a tablet, otherwise false.
42 43 44 |
# File 'lib/platform/mobile/mobile.rb', line 42 def is_tablet? false end |
#password ⇒ Object
Public: Gets the device password.
Returns the password String.
35 36 37 |
# File 'lib/platform/mobile/mobile.rb', line 35 def password super || '1AUTOtest01' end |
#software_version ⇒ Object
Public: Gets the device software version.
Returns the String software version.
21 22 23 |
# File 'lib/platform/mobile/mobile.rb', line 21 def software_version super || 'latest' end |
#username ⇒ Object
Public: Gets the device username.
Returns the username String.
28 29 30 |
# File 'lib/platform/mobile/mobile.rb', line 28 def username super || 'twctvCAT' end |