Permalink
14d1835 Aug 27, 2018
2 contributors

Users who have contributed to this file

@bootstraponline @KazuCocoa
3267 lines (1654 sloc) 87.1 KB
load_settings

def load_settings(opts = {})

Load arbitrary text (toml format) The toml is parsed by https://github.com/fbernier/tomlrb .

[caps]
app = "path/to/app"

[appium_lib]
port = 8080

:app is expanded :require is expanded all keys are converted to symbols

Parameters:

     [Hash] opts - file: '/path/to/appium.txt', verbose: true

Returns:

     [hash] the symbolized hash with updated :app and :require keys

--

load_appium_txt

def load_settings(opts = {})

Load arbitrary text (toml format) The toml is parsed by https://github.com/fbernier/tomlrb .

[caps]
app = "path/to/app"

[appium_lib]
port = 8080

:app is expanded :require is expanded all keys are converted to symbols

Parameters:

     [Hash] opts - file: '/path/to/appium.txt', verbose: true

Returns:

     [hash] the symbolized hash with updated :app and :require keys

--

expand_required_files

def expand_required_files(base_dir, file_paths)

Parameters:

     [String] base_dir - parent directory of loaded appium.txt (toml)

     [String] file_paths -

Returns:

     [Array] list of require files as an array, nil if require doesn't exist

--

promote_singleton_appium_methods

def promote_singleton_appium_methods(modules, driver = $driver)

This method is intended to work with page objects that share a common module. For example, Page::HomePage, Page::SignIn those could be promoted on with Appium.promote_singleton_appium_methods Page

If you are promoting on an individual class then you should use Appium.promote_appium_methods instead. The singleton method is intended only for the shared module use case.

if modules is a module instead of an array, then the constants of that module are promoted on. otherwise, the array of modules will be used as the promotion target.

Parameters:

     [Array] modules - An array of modules

     [Driver] driver - A driver to extend for

--

promote_appium_methods

def promote_appium_methods(class_array, driver = $driver)

Promote appium methods to class instance methods

To promote methods to all classes:

It's better to promote on specific classes instead of Object

Parameters:

     [Array] class_array - An array of classes

     [Driver] driver - A driver to extend for

--

global_webdriver_http_sleep

def global_webdriver_http_sleep

The amount to sleep in seconds before every webdriver http call.

--

global_webdriver_http_sleep=

def global_webdriver_http_sleep=(value)

The amount to sleep in seconds before every webdriver http call.

--

sauce

def sauce

SauceLab's settings

--

sauce_username

def sauce_username

Username for use on Sauce Labs. Set false to disable Sauce, even when SAUCE_USERNAME is in ENV. same as @sauce.username

--

sauce_access_key

def sauce_access_key

Access Key for use on Sauce Labs. Set false to disable Sauce, even when SAUCE_ACCESS_KEY is in ENV. same as @sauce.access_key

--

sauce_endpoint

def sauce_endpoint

Override the Sauce Appium endpoint to allow e.g. TestObject tests same as @sauce.endpoint

--

caps

def caps

from Core read http://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Driver

--

custom_url

def custom_url

Returns the value of attribute custom_url

--

export_session

def export_session

Returns the value of attribute export_session

--

export_session_path

def export_session_path

Returns the value of attribute export_session_path

--

default_wait

def default_wait

Returns the value of attribute default_wait

--

appium_port

def appium_port

Returns the value of attribute appium_port

--

appium_device

def appium_device

Returns the value of attribute appium_device

--

automation_name

def automation_name

Returns the value of attribute automation_name

--

listener

def listener

Returns the value of attribute listener

--

http_client

def http_client

Returns the value of attribute http_client

--

appium_wait_timeout

def appium_wait_timeout

Returns the value of attribute appium_wait_timeout

--

appium_wait_interval

def appium_wait_interval

Returns the value of attribute appium_wait_interval

--

appium_server_status

def appium_server_status

Appium's server version

--

appium_debug

def appium_debug

Boolean debug mode for the Appium Ruby bindings

--

driver

def driver

Returns the driver

Returns:

     [Driver] the driver

--

core

def core

Instance of Appium::Core::Driver

--

initialize

def initialize(opts = {}, global_driver = nil)

Creates a new driver. The driver is defined as global scope by default. We can avoid defining global driver.

Parameters:

     [Object] opts - A hash containing various options.

     [Bool] global_driver - A bool require global driver before initialize.

Returns:

     [Driver]

--

driver_attributes

def driver_attributes

Returns a hash of the driver attributes

--

device_is_android?

def device_is_android?

Returns:

     [Boolean]

--

device_is_ios?

def device_is_ios?

Returns:

     [Boolean]

--

device_is_windows?

def device_is_windows?

Returns:

     [Boolean]

--

automation_name_is_uiautomator2?

def automation_name_is_uiautomator2?

Return true if automationName is 'uiautomator2'

Returns:

     [Boolean]

--

automation_name_is_espresso?

def automation_name_is_espresso?

Return true if automationName is 'Espresso'

Returns:

     [Boolean]

--

automation_name_is_xcuitest?

def automation_name_is_xcuitest?

Return true if automationName is 'XCUITest'

Returns:

     [Boolean]

--

dialect

def dialect

Get the dialect value whether current driver is OSS or W3C

Returns:

     [:oss | :w3c] @example

if dialect == :w3c
  driver.action
        .move_to_location(500, 500).pointer_down(:left)
        .move_to_location(0, 700)
        .release.perform
else
  action = TouchAction.new(driver).press(x: 500, y: 500).move_to(500, 700).release
  action.perform
end

--

check_server_version_xcuitest

def check_server_version_xcuitest

Return true if the target Appium server is over REQUIRED_VERSION_XCUITEST. If the Appium server is under REQUIRED_VERSION_XCUITEST, then error is raised.

Returns:

     [Boolean]

--

appium_server_version

def appium_server_version

Returns the server's version info

Returns:

     [Hash]

--

remote_status

def appium_server_version

Returns the server's version info

Returns:

     [Hash]

--

platform_version

def platform_version

Return the platform version as an array of integers

Returns:

     [Array]

--

appium_client_version

def appium_client_version

Returns the client's version info

Returns:

     [Hash]

--

absolute_app_path

def self.absolute_app_path(opts)

Converts app_path to an absolute path.

opts is the full options hash (caps and appium_lib). If server_url is set then the app path is used as is.

if app isn't set then an error is raised.

Returns:

     [String] APP_PATH as an absolute path

--

server_url

def server_url

Get the server url

Returns:

     [String] the server url

--

restart

def restart

Restarts the driver

Returns:

     [Driver] the driver

--

screenshot

def screenshot(png_save_path)

Takes a png screenshot and saves to the target path.

Parameters:

     [String] png_save_path - the full path to save the png

Returns:

     [File]

--

element_screenshot

def element_screenshot(element, png_save_path)

Takes a png screenshot of particular element's area

Parameters:

     [String] element - Element take a screenshot

     [String] png_save_path - the full path to save the png

Returns:

     [File]

--

driver_quit

def driver_quit

Quits the driver

Returns:

     [void]

--

quit_driver

def driver_quit

Quits the driver

Returns:

     [void]

--

window_size

def window_size

Get the device window's size.

Returns:

     [Selenium::WebDriver::Dimension]

--

start_driver

def start_driver(http_client_ops =

Creates a new global driver and quits the old one if it exists. You can customise http_client as the following

Read http://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Device to understand more what the driver can call instance methods.

Parameters:

     [Hash] http_client_ops - a customizable set of options

Returns:

     [Selenium::WebDriver] the new global driver

--

set_implicit_wait

def set_implicit_wait(wait)

To ignore error for Espresso Driver

--

no_wait

def no_wait

Set implicit wait to zero.

--

set_wait

def set_wait(timeout = nil)

Set implicit wait. Default to @core.default_wait.

Parameters:

     [Integer] timeout - the timeout in seconds

Returns:

     [void]

--

exists

def exists(pre_check = 0, post_check = @core.default_wait)

Returns existence of element.

Example:

exists { button('sign in') } ? puts('true') : puts('false')

Parameters:

     [Integer] pre_check - The amount in seconds to set the wait to before checking existence

     [Integer] post_check - The amount in seconds to set the wait to after checking existence

Returns:

     [Boolean]

--

execute_script

def execute_script(script, *args)

The same as @driver.execute_script

Parameters:

     [String] script - The script to execute

     [*args] args - The args to pass to the script

Returns:

     [Object]

--

find_elements

def find_elements(*args)

Calls @driver.find_elements_with_appium

If you call Appium.promote_appium_methods, you can call find_elements directly.

If you call Appium.promote_appium_methods, you can call find_elements directly.

Parameters:

     [*args] args - The args to use

Returns:

     [Array] Array is empty when no elements are found.

--

find_element

def find_element(*args)

Calls @driver.find_element

If you call Appium.promote_appium_methods, you can call find_element directly.

Parameters:

     [*args] args - The args to use

Returns:

     [Element]

--

DEFAULT_MATCH_THRESHOLD

DEFAULT_MATCH_THRESHOLD = 0.5

Return ImageElement if current view has a partial image

Parameters:

     [String] png_img_path - A path to a partial image you'd like to find

     [Flood] match_threshold - At what normalized threshold to reject

     [Bool] visualize - Makes the endpoint to return an image, which contains the visualized result of the corresponding picture matching operation. This option is disabled by default.

Returns:

     [::Appium::Core::ImageElement]

--

find_element_by_image

def find_element_by_image(png_img_path, match_threshold: DEFAULT_MATCH_THRESHOLD, visualize: false)

--

find_elements_by_image

def find_elements_by_image(png_img_paths, match_threshold: DEFAULT_MATCH_THRESHOLD, visualize: false)

Return ImageElement if current view has partial images

Parameters:

     [[String]] png_img_paths - Paths to a partial image you'd like to find

     [Flood] match_threshold - At what normalized threshold to reject

     [Bool] visualize - Makes the endpoint to return an image, which contains the visualized result of the corresponding picture matching operation. This option is disabled by default.

Returns:

     [[::Appium::Core::ImageElement]]

--

set_location

def set_location(opts = {})

Calls @driver.set_location

Parameters:

     [Hash] opts - consisting of:

Returns:

     [Selenium::WebDriver::Location] the location constructed by the selenium webdriver

--

x

def x

Quit the driver and Pry. quit and exit are reserved by Pry.

Returns:

     [void]

--

username

def username

Username for use on Sauce Labs. Set false to disable Sauce, even when SAUCE_USERNAME is in ENV.

--

access_key

def access_key

Access Key for use on Sauce Labs. Set false to disable Sauce, even when SAUCE_ACCESS_KEY is in ENV.

--

endpoint

def endpoint

Override the Sauce Appium endpoint to allow e.g. TestObject tests. Default is 'ondemand.saucelabs.com:443/wd/hub'.

--

initialize

def initialize(appium_lib_opts)

Create a SauceLabs instance to manage sauce labs related attributes.

Parameters:

     [Hash] appium_lib_opts - Appium library parameter

Returns:

     [Appium::SauceLabs]

--

sauce_server_url?

def sauce_server_url?

Return true if an instance of Appium::SauceLabs has sauce_username and sauce_access_key.

Returns:

     [Boolean]

--

server_url

def server_url

Return a particular server url to access to. Default is the local address.

Returns:

     [String]

--

get_log

def get_log(type)

Parameters:

     [String|Hash] type - You can get particular type's logs.

Returns:

     [[Selenium::WebDriver::LogEntry]] A list of logs data.

--

get_available_log_types

def get_available_log_types

Get a list of available log types

Returns:

     [[String]] A list of available log types.

--

wait_true

def wait_true(opts = {})

Check every interval seconds to see if yield returns a truthy value. Note this isn't a strict boolean true, any truthy value is accepted. false and nil are considered failures. Give up after timeout seconds.

Wait code from the selenium Ruby gem https://github.com/SeleniumHQ/selenium/blob/cf501dda3f0ed12233de51ce8170c0e8090f0c20/rb/lib/selenium/webdriver/common/wait.rb

If only a number is provided then it's treated as the timeout value.

Parameters:

     [Hash|Numeric] opts - Options. If the value is Numeric, the value is set as { timeout: value }

--

wait

def wait(opts = {})

Check every interval seconds to see if yield doesn't raise an exception. Give up after timeout seconds.

Wait code from the selenium Ruby gem https://github.com/SeleniumHQ/selenium/blob/cf501dda3f0ed12233de51ce8170c0e8090f0c20/rb/lib/selenium/webdriver/common/wait.rb

If only a number is provided then it's treated as the timeout value.

Parameters:

     [Hash|Numeric] opts - Options. If the value is Numeric, the value is set as { timeout: value }

--

add_touch_actions

def add_touch_actions

--

delegate_from_appium_driver

def delegate_from_appium_driver(method, delegation_target)

--

ignore

def ignore

Return yield and ignore any exceptions.

--

back

def back

Navigate back.

Returns:

     [void]

--

session_id

def session_id

For Sauce Labs reporting. Returns the current session id.

Returns:

     [String]

--

xpath

def xpath(xpath_str)

Returns the first element that matches the provided xpath.

Parameters:

     [String] xpath_str - the XPath string

Returns:

     [Element]

--

xpaths

def xpaths(xpath_str)

Returns all elements that match the provided xpath.

Parameters:

     [String] xpath_str - the XPath string

Returns:

     [Array]

--

result

def result

Returns the value of attribute result

--

initialize

def initialize(platform)

Returns:

     [CountElements] a new instance of CountElements

--

reset

def reset

--

start_element

def start_element(name, attrs = [])

http://nokogiri.org/Nokogiri/XML/SAX/Document.html

--

formatted_result

def formatted_result

--

get_page_class

def get_page_class

Returns a string of class counts of visible elements.

Returns:

     [String]

--

page_class

def page_class

Count all classes on screen and print to stdout. Useful for appium_console.

Returns:

     [nil]

--

source

def source

Prints xml of the current page

Returns:

     [void]

--

get_source

def get_source

Returns XML string for the current page Same as driver.page_source

Returns:

     [String]

--

px_to_window_rel

def px_to_window_rel(opts = {}, driver = $driver)

Converts pixel values to window relative values

--

xml_keys

def xml_keys(target)

Search strings.xml's values for target.

Parameters:

     [String] target - the target to search for in strings.xml values

Returns:

     [Array]

--

xml_values

def xml_values(target)

Search strings.xml's keys for target.

Parameters:

     [String] target - the target to search for in strings.xml keys

Returns:

     [Array]

--

resolve_id

def resolve_id(id)

Resolve id in strings.xml and return the value.

Parameters:

     [String] id - the id to resolve

Returns:

     [String]

--

filter

def filter

Returns the value of attribute filter

--

filter=

def filter=(value)

convert to string to support symbols

--

initialize

def initialize

Returns:

     [HTMLElements] a new instance of HTMLElements

--

reset

def reset

--

result

def result

--

start_element

def start_element(name, attrs = [])

--

end_element

def end_element(name)

--

characters

def characters(chars)

--

DEFAULT_HEADERS

DEFAULT_HEADERS = { 'Accept' => CONTENT_TYPE, 'User-Agent' => "appium/ruby_lib/#{::Appium::VERSION}" }.freeze

Default HTTP client inherit Appium::Core::Base::Http::Default, but has different DEFAULT_HEADERS

--

pinch

def pinch(percentage = 25, auto_perform = true, driver = $driver)

Convenience method for pinching the screen. Places two fingers at the edges of the screen and brings them together. Without auto_perform

With driver

Parameters:

     [int] percentage - The percent size by which to shrink the screen when pinched.

     [boolean] auto_perform - Whether to perform the action immediately (default true)

     [Driver] driver - Set a driver to conduct the action. DEfault is global driver($driver)

--

zoom

def zoom(percentage = 200, auto_perform = true, driver = $driver)

Convenience method for zooming the screen. Places two fingers at the edges of the screen and brings them together. Without auto_perform

With driver

Parameters:

     [int] percentage - The percent size by which to shrink the screen when pinched.

     [boolean] auto_perform - Whether to perform the action immediately (default true)

     [Driver] driver - Set a driver to conduct the action. DEfault is global driver($driver)

--

initialize

def initialize(driver = $driver)

self

Returns:

     [MultiTouch] a new instance of MultiTouch

--

COMPLEX_ACTIONS

COMPLEX_ACTIONS = ::Appium::Core::TouchAction::COMPLEX_ACTIONS

--

initialize

def initialize(driver = $driver)

Returns:

     [TouchAction] a new instance of TouchAction

--

swipe

def swipe(opts)

--

initialize

def initialize(url:, output_file: 'logcat.log')

Returns:

     [WsLogcat] a new instance of WsLogcat

--

handle_message_data

def handle_message_data(data)

--

for ios

def self.for(target)

--

UIAStaticText ios

UIAStaticText = 'UIAStaticText'.freeze

--

XCUIElementTypeStaticText ios

XCUIElementTypeStaticText = 'XCUIElementTypeStaticText'.freeze

--

static_text_class ios

def static_text_class

Returns:

     [String] Class name for text

--

text ios

def text(value)

Find the first UIAStaticText|XCUIElementTypeStaticText that contains value or by index. If int then the UIAStaticText|XCUIElementTypeStaticText at that index is returned.

Parameters:

     [String, Integer] value - the value to find.

Returns:

     [UIAStaticText|XCUIElementTypeStaticText]

--

texts ios

def texts(value = false)

Find all UIAStaticTexts|XCUIElementTypeStaticTexts containing value. If value is omitted, all UIAStaticTexts|XCUIElementTypeStaticTexts are returned

Parameters:

     [String] value - the value to search for

Returns:

     [Array<UIAStaticText|XCUIElementTypeStaticText>]

--

first_text ios

def first_text

Find the first UIAStaticText|XCUIElementTypeStaticText.

Returns:

     [UIAStaticText|XCUIElementTypeStaticText]

--

last_text ios

def last_text

Find the last UIAStaticText|XCUIElementTypeStaticText.

Returns:

     [UIAStaticText|XCUIElementTypeStaticText]

--

text_exact ios

def text_exact(value)

Find the first UIAStaticText|XCUIElementTypeStaticText that exactly matches value.

Parameters:

     [String] value - the value to match exactly

Returns:

     [UIAStaticText|XCUIElementTypeStaticText]

--

texts_exact ios

def texts_exact(value)

Find all UIAStaticTexts|XCUIElementTypeStaticTexts that exactly match value.

Parameters:

     [String] value - the value to match exactly

Returns:

     [Array<UIAStaticText|XCUIElementTypeStaticText>]

--

filter ios

def filter

Returns the value of attribute filter

--

filter= ios

def filter=(value)

Sets the attribute filter

Parameters:

     value - the value to set the attribute filter to.

--

start_element ios

def start_element(type, attrs = [])

--

ios_password ios

def ios_password(length = 1)

iOS only. On Android uiautomator always returns an empty string for EditText password.

Password character returned from value of UIASecureTextField

Parameters:

     [Integer] length - the length of the password to generate

Returns:

     [String] the returned string is of size length

--

page ios

def page(opts = {})

Prints a string of interesting elements to the console.

Parameters:

     [Hash] visible - a customizable set of options

     [Hash] class - a customizable set of options

Returns:

     [void]

--

id ios

def id(id)

Find by id

Parameters:

     [String] id - the id to search for

Returns:

     [Element]

--

ele_index ios

def ele_index(class_name, index)

Get the element of type class_name at matching index.

Parameters:

     [String] class_name - the class name to find

     [Integer] index - the index

Returns:

     [Element]

--

find_ele_by_attr ios

def find_ele_by_attr(class_name, attr, value)

Find the first element exactly matching class and attribute value. Note: Uses XPath Note: For XCUITest, this method return ALL elements include displayed or not displayed elements.

Parameters:

     [String] class_name - the class name to search for

     [String] attr - the attribute to inspect

     [String] value - the expected value of the attribute

Returns:

     [Element]

--

find_eles_by_attr ios

def find_eles_by_attr(class_name, attr, value)

Find all elements exactly matching class and attribute value. Note: Uses XPath Note: For XCUITest, this method return ALL elements include displayed or not displayed elements.

Parameters:

     [String] class_name - the class name to match

     [String] attr - the attribute to compare

     [String] value - the value of the attribute that the element must have

Returns:

     [Array]

--

find_ele_by_predicate ios

def find_ele_by_predicate(class_name: '*', value:)

Find the first element exactly matching attribute case insensitive value. Note: Uses Predicate

Parameters:

     [String] value - the expected value of the attribute

Returns:

     [Element]

--

find_eles_by_predicate ios

def find_eles_by_predicate(class_name: '*', value:)

Find all elements exactly matching attribute case insensitive value. Note: Uses Predicate

Parameters:

     [String] value - the value of the attribute that the element must have

     [String] class_name - the tag name to match

Returns:

     [Array]

--

find_ele_by_attr_include ios

def find_ele_by_attr_include(class_name, attr, value)

Get the first tag by attribute that exactly matches value. Note: Uses XPath

Parameters:

     [String] class_name - the tag name to match

     [String] attr - the attribute to compare

     [String] value - the value of the attribute that the element must include

Returns:

     [Element] the element of type tag who's attribute includes value

--

find_eles_by_attr_include ios

def find_eles_by_attr_include(class_name, attr, value)

Get tags by attribute that include value. Note: Uses XPath

Parameters:

     [String] class_name - the tag name to match

     [String] attr - the attribute to compare

     [String] value - the value of the attribute that the element must include

Returns:

     [Array] the elements of type tag who's attribute includes value

--

find_ele_by_predicate_include ios

def find_ele_by_predicate_include(class_name: '*', value:)

Get the first elements that include insensitive value. Note: Uses Predicate

Parameters:

     [String] value - the value of the attribute that the element must include

Returns:

     [Element] the element of type tag who's attribute includes value

--

find_eles_by_predicate_include ios

def find_eles_by_predicate_include(class_name: '*', value:)

Get elements that include case insensitive value. Note: Uses Predicate

Parameters:

     [String] value - the value of the attribute that the element must include

     [String] class_name - the tag name to match

Returns:

     [Array] the elements of type tag who's attribute includes value

--

first_ele ios

def first_ele(class_name)

Get the first tag that matches class_name

Parameters:

     [String] class_name - the tag to match

Returns:

     [Element]

--

last_ele ios

def last_ele(class_name)

Get the last tag that matches class_name

Parameters:

     [String] class_name - the tag to match

Returns:

     [Element]

--

tag ios

def tag(class_name)

Returns the first visible element matching class_name

Parameters:

     [String] class_name - the class_name to search for

Returns:

     [Element]

--

tags ios

def tags(class_name)

Returns all visible elements matching class_name

Parameters:

     [String] class_name - the class_name to search for

Returns:

     [Element]

--

tags_include ios

def tags_include(class_names:, value: nil)

Returns all visible elements matching class_names and value This method calls find_element/s and element.value/text many times. So, if you set many class_names, this method's performance become worse.

Parameters:

     [Array[String]] class_names - the class_names to search for

     [String] value - the value to search for

Returns:

     [Array[Element]]

--

tags_exact ios

def tags_exact(class_names:, value: nil)

Returns all visible elements matching class_names and value. This method calls find_element/s and element.value/text many times. So, if you set many class_names, this method's performance become worse.

Parameters:

     [Array[String]] class_names - the class_names to search for

     [String] value - the value to search for

Returns:

     [Array[Element]]

--

ele_by_json_visible_contains ios

def ele_by_json_visible_contains(element, value)

Find the first element that contains value. For Appium(automation name), not XCUITest

Parameters:

     [String] element - the class name for the element

     [String] value - the value to search for

Returns:

     [Element]

--

eles_by_json_visible_contains ios

def eles_by_json_visible_contains(element, value)

Find all elements containing value For Appium(automation name), not XCUITest

Parameters:

     [String] element - the class name for the element

     [String] value - the value to search for

Returns:

     [Array]

--

ele_by_json_visible_exact ios

def ele_by_json_visible_exact(element, value)

Find the first element exactly matching value For Appium(automation name), not XCUITest

Parameters:

     [String] element - the class name for the element

     [String] value - the value to search for

Returns:

     [Element]

--

eles_by_json_visible_exact ios

def eles_by_json_visible_exact(element, value)

Find all elements exactly matching value For Appium(automation name), not XCUITest

Parameters:

     [String] element - the class name for the element

     [String] value - the value to search for

Returns:

     [Element]

--

_all_pred ios

def _all_pred(opts)

predicate - the predicate to evaluate on the main app

visible - if true, only visible elements are returned. default true

--

ele_with_pred ios

def ele_with_pred(opts)

returns element matching predicate contained in the main app

predicate - the predicate to evaluate on the main app

visible - if true, only visible elements are returned. default true

Returns:

     [Element]

--

eles_with_pred ios

def eles_with_pred(opts)

returns elements matching predicate contained in the main app

predicate - the predicate to evaluate on the main app

visible - if true, only visible elements are returned. default true

Returns:

     [Array]

--

_validate_object ios

def _validate_object(*objects)

--

_by_json ios

def _by_json(opts)

For Appium(automation name), not XCUITest typeArray - array of string types to search for. Example: ["UIAStaticText"] onlyFirst - boolean. returns only the first result if true. Example: true onlyVisible - boolean. returns only visible elements if true. Example: true target - string. the target value to search for. Example: "Buttons, Various uses of UIButton" substring - boolean. matches on substrings if true otherwise an exact mathc is required. Example: true insensitive - boolean. ignores case sensitivity if true otherwise it's case sensitive. Example: true

opts = { typeArray: ["UIAStaticText"], onlyFirst: true, onlyVisible: true, name: { target: "Buttons, Various uses of UIButton", substring: false, insensitive: false, }, label: { target: "Buttons, Various uses of UIButton", substring: false, insensitive: false, }, value: { target: "Buttons, Various uses of UIButton", substring: false, insensitive: false, } }

--

eles_by_json ios

def eles_by_json(opts)

For Appium(automation name), not XCUITest example usage:

eles_by_json({ typeArray: ["UIAStaticText"], onlyVisible: true, name: { target: "Buttons, Various uses of UIButton", substring: false, insensitive: false, }, })

--

ele_by_json ios

def ele_by_json(opts)

see eles_by_json

--

alert_accept ios

def alert_accept

Accept the alert.

Returns:

     [void]

--

alert_dismiss ios

def alert_dismiss

Dismiss the alert.

Returns:

     [void]

--

UIAButton ios

UIAButton = 'UIAButton'.freeze

--

XCUIElementTypeButton ios

XCUIElementTypeButton = 'XCUIElementTypeButton'.freeze

--

button_class ios

def button_class

Returns:

     [String] Class name for button

--

button ios

def button(value)

Find the first UIAButton|XCUIElementTypeButton that contains value or by index. If int then the UIAButton|XCUIElementTypeButton at that index is returned.

Parameters:

     [String, Integer] value - the value to exactly match.

Returns:

     [UIAButton|XCUIElementTypeButton]

--

buttons ios

def buttons(value = false)

Find all UIAButtons|XCUIElementTypeButtons containing value. If value is omitted, all UIAButtons|XCUIElementTypeButtons are returned.

Parameters:

     [String] value - the value to search for

Returns:

     [Array<UIAButton|XCUIElementTypeButton>]

--

first_button ios

def first_button

Find the first UIAButton|XCUIElementTypeButton.

Returns:

     [UIAButton|XCUIElementTypeButton]

--

last_button ios

def last_button

TODO: add documentation regarding previous element. Previous UIAElement is differ from UIAButton|XCUIElementTypeButton. So, the results are different. Find the last UIAButton|XCUIElementTypeButton.

Returns:

     [UIAButton|XCUIElementTypeButton]

--

button_exact ios

def button_exact(value)

Find the first UIAButton|XCUIElementTypeButton that exactly matches value.

Parameters:

     [String] value - the value to match exactly

Returns:

     [UIAButton|XCUIElementTypeButton]

--

buttons_exact ios

def buttons_exact(value)

Find all UIAButtons|XCUIElementTypeButtons that exactly match value.

Parameters:

     [String] value - the value to match exactly

Returns:

     [Array<UIAButton|XCUIElementTypeButton>]

--

find ios

def find(value)

Find the first element containing value

Parameters:

     [String] value - the value to search for

Returns:

     [Element]

--

finds ios

def finds(value)

Find all elements containing value

Parameters:

     [String] value - the value to search for

Returns:

     [Array]

--

find_exact ios

def find_exact(value)

Find the first element exactly matching value

Parameters:

     [String] value - the value to search for

Returns:

     [Element]

--

finds_exact ios

def finds_exact(value)

Find all elements exactly matching value

Parameters:

     [String] value - the value to search for

Returns:

     [Array]

--

raise_error_if_no_element ios

def raise_error_if_no_element(element)

--

select_visible_elements ios

def select_visible_elements(elements)

Return visible elements.

--

for ios

def self.for(target)

--

last_ele ios

def last_ele(class_name)

Get the last tag that matches class_name

Parameters:

     [String] class_name - the tag to match

Returns:

     [Element]

--

tag ios

def tag(class_name)

Returns the first visible element matching class_name

Parameters:

     [String] class_name - the class_name to search for

Returns:

     [Element]

--

tags ios

def tags(class_name)

Returns all visible elements matching class_name

Parameters:

     [String] class_name - the class_name to search for

Returns:

     [Element]

--

tags_include ios

def tags_include(class_names:, value: nil)

Returns all visible elements matching class_names and value This method calls find_element/s and element.value/text many times. So, if you set many class_names, this method's performance become worse.

Parameters:

     [Array[String]] class_names - the class_names to search for

     [String] value - the value to search for

Returns:

     [Array[Element]]

--

tags_exact ios

def tags_exact(class_names:, value: nil)

Returns all visible elements matching class_names and value. This method calls find_element/s and element.value/text many times. So, if you set many class_names, this method's performance become worse.

Parameters:

     [Array[String]] class_names - the class_names to search for

     [String] value - the value to search for

Returns:

     [Array[Element]]

--

start_logs_broadcast ios

def start_logs_broadcast(syslog_file = 'syslog.log')

Starts iOS syslog broadcast websocket

Parameters:

     [String] syslog_file - A file path to write messages from a syslog WebSocket client

--

stop_logs_broadcast ios

def stop_logs_broadcast

Stop iOS syslog broadcast websocket

--

UIATextField ios

UIATextField = 'UIATextField'.freeze

--

UIASecureTextField ios

UIASecureTextField = 'UIASecureTextField'.freeze

--

XCUIElementTypeTextField ios

XCUIElementTypeTextField = 'XCUIElementTypeTextField'.freeze

--

XCUIElementTypeSecureTextField ios

XCUIElementTypeSecureTextField = 'XCUIElementTypeSecureTextField'.freeze

--

text_field_class ios

def text_field_class

Returns:

     [String] Class name for text field

--

secure_text_field_class ios

def secure_text_field_class

Returns:

     [String] Class name for secure text field

--

textfield ios

def textfield(value)

Find the first TextField that contains value or by index. Note: Uses XPath If int then the TextField at that index is returned.

Parameters:

     [String, Integer] value - the text to match exactly.

Returns:

     [TextField]

--

textfields ios

def textfields(value = false)

Find all TextFields containing value. If value is omitted, all TextFields are returned.

Parameters:

     [String] value - the value to search for

Returns:

     [Array]

--

first_textfield ios

def first_textfield

Find the first TextField.

Returns:

     [TextField]

--

last_textfield ios

def last_textfield

Find the last TextField.

Returns:

     [TextField]

--

textfield_exact ios

def textfield_exact(value)

Find the first TextField that exactly matches value.

Parameters:

     [String] value - the value to match exactly

Returns:

     [TextField]

--

textfields_exact ios

def textfields_exact(value)

Find all TextFields that exactly match value.

Parameters:

     [String] value - the value to match exactly

Returns:

     [Array]

--

_textfield_visible ios

def _textfield_visible

Appium

--

_textfield_exact_string ios

def _textfield_exact_string(value)

Appium

--

_textfield_contains_string ios

def _textfield_contains_string(value)

Appium

--

static_text_class ios

def static_text_class

Returns:

     [String] Class name for text

--

text ios

def text(value)

Find the first UIAStaticText|XCUIElementTypeStaticText that contains value or by index. If int then the UIAStaticText|XCUIElementTypeStaticText at that index is returned.

Parameters:

     [String, Integer] value - the value to find.

Returns:

     [UIAStaticText|XCUIElementTypeStaticText]

--

texts ios

def texts(value = false)

Find all UIAStaticTexts|XCUIElementTypeStaticTexts containing value. If value is omitted, all UIAStaticTexts|XCUIElementTypeStaticTexts are returned

Parameters:

     [String] value - the value to search for

Returns:

     [Array<UIAStaticText|XCUIElementTypeStaticText>]

--

first_text ios

def first_text

Find the first UIAStaticText|XCUIElementTypeStaticText.

Returns:

     [UIAStaticText|XCUIElementTypeStaticText]

--

last_text ios

def last_text

Find the last UIAStaticText|XCUIElementTypeStaticText.

Returns:

     [UIAStaticText|XCUIElementTypeStaticText]

--

text_exact ios

def text_exact(value)

Find the first UIAStaticText|XCUIElementTypeStaticText that exactly matches value.

Parameters:

     [String] value - the value to match exactly

Returns:

     [UIAStaticText|XCUIElementTypeStaticText]

--

texts_exact ios

def texts_exact(value)

Find all UIAStaticTexts|XCUIElementTypeStaticTexts that exactly match value.

Parameters:

     [String] value - the value to match exactly

Returns:

     [Array<UIAStaticText|XCUIElementTypeStaticText>]

--

xcuitest_source ios

def xcuitest_source(format: :xml)

Parameters:

     [String|Symbol] format - :xml or :json. :xml is by default.

     [Hash] opts - a customizable set of options

--

button_class ios

def button_class

Returns:

     [String] Class name for button

--

button ios

def button(value)

Find the first UIAButton|XCUIElementTypeButton that contains value or by index. If int then the UIAButton|XCUIElementTypeButton at that index is returned.

Parameters:

     [String, Integer] value - the value to exactly match.

Returns:

     [UIAButton|XCUIElementTypeButton]

--

buttons ios

def buttons(value = false)

Find all UIAButtons|XCUIElementTypeButtons containing value. If value is omitted, all UIAButtons|XCUIElementTypeButtons are returned.

Parameters:

     [String] value - the value to search for

Returns:

     [Array<UIAButton|XCUIElementTypeButton>]

--

first_button ios

def first_button

Find the first UIAButton|XCUIElementTypeButton.

Returns:

     [UIAButton|XCUIElementTypeButton]

--

last_button ios

def last_button

TODO: add documentation regarding previous element. Previous UIAElement is differ from UIAButton|XCUIElementTypeButton. So, the results are different. Find the last UIAButton|XCUIElementTypeButton.

Returns:

     [UIAButton|XCUIElementTypeButton]

--

button_exact ios

def button_exact(value)

Find the first UIAButton|XCUIElementTypeButton that exactly matches value.

Parameters:

     [String] value - the value to match exactly

Returns:

     [UIAButton|XCUIElementTypeButton]

--

buttons_exact ios

def buttons_exact(value)

Find all UIAButtons|XCUIElementTypeButtons that exactly match value.

Parameters:

     [String] value - the value to match exactly

Returns:

     [Array<UIAButton|XCUIElementTypeButton>]

--

find ios

def find(value)

Find the first element containing value

Parameters:

     [String] value - the value to search for

Returns:

     [Element]

--

finds ios

def finds(value)

Find all elements containing value

Parameters:

     [String] value - the value to search for

Returns:

     [Array]

--

find_exact ios

def find_exact(value)

Find the first element exactly matching value

Parameters:

     [String] value - the value to search for

Returns:

     [Element]

--

finds_exact ios

def finds_exact(value)

Find all elements exactly matching value

Parameters:

     [String] value - the value to search for

Returns:

     [Array]

--

raise_error_if_no_element ios

def raise_error_if_no_element(element)

--

select_visible_elements ios

def select_visible_elements(elements)

Return visible elements.

--

swipe ios

def swipe(direction:, element: nil)

Parameters:

     [string] direction - Either 'up', 'down', 'left' or 'right'.

     [Hash] opts - a customizable set of options

--

scroll ios

def scroll(direction:, # rubocop:disable Metrics/ParameterLists

Parameters:

     [string] direction - Either 'up', 'down', 'left' or 'right'.

     [Hash] opts - a customizable set of options

--

pinch ios

def pinch(scale:, velocity: 1.0, element: nil)

Parameters:

     [scale] scale - X tap coordinate of type float. Mandatory parameter

     [float] velocity - Y tap coordinate of type float. Mandatory parameter

     [Hash] opts - a customizable set of options

--

double_tap ios

def double_tap(x: nil, y: nil, element: nil)

Parameters:

     [float] x - X Screen x tap coordinate of type float. Mandatory parameter only if element is not set

     [float] y - Y Screen y tap coordinate of type float. Mandatory parameter only if element is not set

     [Hash] opts - a customizable set of options

--

touch_and_hold ios

def touch_and_hold(x: nil, y: nil, element: nil, duration: 1.0)

Parameters:

     [float] x - Screen x long tap coordinate of type float. Mandatory parameter only if element is not set

     [float] y - Screen y long tap coordinate of type float. Mandatory parameter only if element is not set

     [Float] duration - The float duration of press action in seconds. Mandatory parameter

     [Hash] opts - a customizable set of options

--

two_finger_tap ios

def two_finger_tap(element:)

Parameters:

     [Element] element - Element to long tap on.

two_finger_tap element: find_element(:accessibility_id, "some item")

--

tap ios

def tap(x:, y:, element: nil)

Parameters:

     [float] x - X tap coordinate of type float. Mandatory parameter

     [float] y - Y tap coordinate of type float. Mandatory parameter

     [Hash] opts - a customizable set of options

--

drag_from_to_for_duration ios

def drag_from_to_for_duration(from_x:, from_y:, to_x:, to_y:, duration: 1.0, element: nil)

rubocop:disable Metrics/ParameterLists

Parameters:

     [float] duration - Float number of seconds in range [0.5, 60]. How long the tap gesture at starting drag point should be before to start dragging. Mandatory parameter

     [float] from_x - The x coordinate of starting drag point (type float). Mandatory parameter

     [float] from_y - The y coordinate of starting drag point (type float). Mandatory parameter

     [float] to_x - The x coordinate of ending drag point (type float). Mandatory parameter

     [float] to_y - The y coordinate of ending drag point (type float). Mandatory parameter

     [Hash] opts - a customizable set of options

--

select_picker_wheel ios

def select_picker_wheel(element:, order:, offset: nil)

https://github.com/facebook/WebDriverAgent/pull/523 https://github.com/appium/appium-xcuitest-driver/pull/420

Parameters:

     [String] order - The order to move picker to. "next" or "previous".

     [Element] element - Element id to perform select picker wheel on.

     [Hash] opts - a customizable set of options

--

alert ios

def alert(action:, button_label: nil)

Parameters:

     [String] action - The following actions are supported: accept, dismiss and getButtons. Mandatory parameter

     [String] button_label - The label text of an existing alert button to click on. This is an optional parameter and is only valid in combination with accept and dismiss actions.

--

text_field_class ios

def text_field_class

Returns:

     [String] Class name for text field

--

secure_text_field_class ios

def secure_text_field_class

Returns:

     [String] Class name for secure text field

--

textfield ios

def textfield(value)

Find the first TextField that contains value or by index. Note: Uses XPath If int then the TextField at that index is returned.

Parameters:

     [String, Integer] value - the text to match exactly.

Returns:

     [TextField]

--

textfields ios

def textfields(value = false)

Find all TextFields containing value. If value is omitted, all TextFields are returned.

Parameters:

     [String] value - the value to search for

Returns:

     [Array]

--

first_textfield ios

def first_textfield

Find the first TextField.

Returns:

     [TextField]

--

last_textfield ios

def last_textfield

Find the last TextField.

Returns:

     [TextField]

--

textfield_exact ios

def textfield_exact(value)

Find the first TextField that exactly matches value.

Parameters:

     [String] value - the value to match exactly

Returns:

     [TextField]

--

textfields_exact ios

def textfields_exact(value)

Find all TextFields that exactly match value.

Parameters:

     [String] value - the value to match exactly

Returns:

     [Array]

--

set_pasteboard ios

def set_pasteboard(content:, encoding: nil)

Parameters:

     [string] content - The content of the pasteboard. The previous content is going to be overridden. The parameter is mandatory

     [Hash] opts - a customizable set of options

--

get_pasteboard ios

def get_pasteboard(encoding: nil)

Parameters:

     [Hash] opts - a customizable set of options

--

install_certificate ios

def install_certificate(cer_file:)

Generates Apple's over-the-air configuration profile for certificate deployment based on the given PEM certificate content. https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/iPhoneOTAConfiguration/Introduction/Introduction.html https://github.com/appium/appium-xcuitest-driver/pull/652

Parameters:

     [string] cer_file - The content of the certificate file.

--

xcuitest_get_contexts ios

def xcuitest_get_contexts

Get contexts

--

xcuitest_install_app ios

def xcuitest_install_app(app:)

Installs given application to the device under test. If the same application is already installed then it's going to be installed over it, which allows to test upgrades. Be careful while reinstalling the main application under test - make sure you called terminateApp for it first, otherwise WebDriverAgent will detect it as a potential application crash.

Parameters:

     [String] app - The path to an existing .ipa/.app file on the server file system, zipped .app file or an URL pointing to a remote .ipa/.zip file. Mandatory argument.

--

xcuitest_app_installed? ios

def xcuitest_app_installed?(bundle_id:)

Verifies whether the application with given bundle identifier is installed on the device.

Parameters:

     [String] bundle_id - The bundle identifier of the application, which is going to be verified.

Returns:

     [boolean]

--

xcuitest_remove_app ios

def xcuitest_remove_app(bundle_id:)

Uninstalls an existing application from the device under test. This endpoint does not verify whether the application is already installed or not before uninstalling it.

Parameters:

     [String] bundle_id - The bundle identifier of the application, which is going to be uninstalled.

--

xcuitest_launch_app ios

def xcuitest_launch_app(bundle_id:)

Executes an existing application on the device. If the application is already running then it will be brought to the foreground.

Parameters:

     [String] bundle_id - The bundle identifier of the application, which is going to be executed.

--

xcuitest_terminate_app ios

def xcuitest_terminate_app(bundle_id:)

Terminates an existing application on the device. If the application is not running then the returned result will be false, otherwise true.

Parameters:

     [String] bundle_id - The bundle identifier of the application, which is going to be terminated.

--

xcuitest_query_app_status ios

def xcuitest_query_app_status(bundle_id:)

Get the status of an existing application on the device. State: 0: The current application state cannot be determined/is unknown 1: The application is not running 2: The application is running in the background and is suspended 3: The application is running in the background and is not suspended 4: The application is running in the foreground

For more details: https://developer.apple.com/documentation/xctest/xcuiapplicationstate

Parameters:

     [String] bundle_id - A target app's bundle id

Returns:

     [0|1|2|3|4] A number of the state

--

xcuitest_activate_app ios

def xcuitest_activate_app(bundle_id:)

Activates an existing application on the device under test and moves it to the foreground. The application should be already running in order to activate it. The call is ignored if the application is already in foreground.

Parameters:

     [String] bundle_id - The bundle identifier of the application, which is going to be brought to the foreground.

--