mob
Provides methods for mobile automation.
Locators:
Native application locators for
    /XPATH - Locates element using an XPath 1.0 expression.
    ~ACCESSIBILITY_ID - Locates element by its Accessibility Id.
    id=ID - Locates element by its id.
    class=CLASS - Locates element by its class.
    text=TEXT - Locates element by its visible text.
    text-contains=TEXT - Locates element whose visible text contains the specified string.
    desc=DESCRIPTION - Locates element by its description.
    desc-contains=DESCRIPTION - Locates element whose description contains the specified string.
    scrollable - Locates elements that are scrollable.
Native application locators for
    /XPATH - Locates element using an XPath 1.0 expression.
    id=ID - Locates element by its ID.
    ~ACCESSIBILITY_ID - Locates element by its Accessibility Id.
Hybrid
and Web
application locators for
    /XPATH - Locates element using an XPath 1.0 expression.
    id=ID - Locates element by its id.
    name=NAME - Locates element by its name attribute.
    tag=NAME - Locates element by its tag name.
    link=TEXT - Locates anchor element whose text matches the given string.
    link-contains=TEXT - Locates anchor element whose text contains the given string.
    css=CSS_SELECTOR - Locates element using a CSS selector.
Pattern arguments:
Commands which expect a string matching pattern in their arguments, support following patterns unless specified otherwise:
    regex:PATTERN - Match using regular expression.
    PATTERN - Verbatim matching.

alertAccept

Accepts an alert or a confirmation dialog.
In case of an alert box this command is identical to alertDismiss.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.click("id=Submit");// Clicks an element and opens an alert.
3
mob.alertAccept();//Automatically press on 'OK' button in the alert pop-up.
Copied!
Supported On:

alertDismiss

Dismisses an alert or a confirmation dialog.
In case of an alert box this command is identical to alertAccept.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.click("id=Submit");// Clicks an element and opens an alert.
3
mob.alertDismiss();//Automatically press on 'Cancel' button in the alert pop-up.
Copied!
Supported On:

assertAlert

Asserts whether alert matches the specified pattern and dismisses it.
Text pattern can be any of the supported string matching patterns(on the top of page).
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.click("id=Submit");// Clicks an element and opens an alert.
3
mob.assertAlert("Your Alert's text");//Asserts the alert's text.
Copied!
Parameters:
Name
Type
Description
pattern
String
Text pattern.
timeout
Number
optional Timeout in milliseconds. Default is 60 seconds.
Supported On:

assertText

Asserts element's inner text.
Text pattern can be any of the supported string matching patterns (on the top of page). If the element is not interactable, then it will allways return empty string as its text.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.assertText("id=UserName","John Doe");// Asserts if an element’s text is as expected.
Copied!
Parameters:
Name
Type
Description
locator
String|Element
Element locator.
pattern
String
Assertion text or pattern.
timeout
Number
optional Timeout in milliseconds. Default is 60 seconds.
Supported On:

assertTitle

Asserts the page title.
Assertion pattern can be any of the supported string matching patterns(on the top of page).
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.assertTitle("Your websites title!");// Asserts if the title of the page.
Copied!
Parameters:
Name
Type
Description
pattern
String
Assertion text or pattern.
timeout
Number
optional Timeout in milliseconds. Default is 60 seconds.
Supported On:

assertValue

Asserts element's value.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.assertValue("id=UserName", "John Doe");// Asserts if the value of an element.
Copied!
Parameters:
Name
Type
Description
locator
String|Element
Element locator.
pattern
String
Value pattern.
timeout
Number
optional Timeout in milliseconds. Default is 60 seconds.
Supported On:

back

Navigate backwards in the browser history or simulates back button on Android device.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.click("id=NextPage);// Clicks an element and opens an alert.
3
mob.back();//Navigate back to previous page.
Copied!
Supported On:

clear

Clears element's value or content
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.type("id=Password", "Password");//Types a password to a field.
3
mob.clear("id=Password");//Clears the characters from the field of an element.
Copied!
Parameters:
Name
Type
Description
locator
String|Element
Element locator.
timeout
Number
optional Timeout in milliseconds. Default is 60 seconds.
Supported On:

click

Clicks on an element.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.click("id=Submit");// Clicks an element.
Copied!
Parameters:
Name
Type
Description
locator
String|Element
Element locator.
timeout
Number
optional Timeout in milliseconds. Default is 60 seconds.
Supported On:

clickHidden

Clicks on a non-visible element.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.clickHidden("id=hiddenContent);// Clicks an hidden element.
Copied!
Parameters:
Name
Type
Description
locator
String|Element
Element locator.
clickParent
Boolean
optional If true, then parent of the element is clicked.
Supported On:

clickLong

Performs a long click/touch on an element.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.clickLong("id=Mark",6000);// Clicks an element for a certain duration.
Copied!
Parameters:
Name
Type
Description
locator
String|Element
Element locator.
duration
Number
Touch duration in milliseconds.
timeout
Number
optional Timeout in milliseconds. Default is 60 seconds.
Supported On:

clickMultipleTimes

Performs tap on an element multiple times in quick succession.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.clickMultipleTimes("id=Mark",4);// Clicks an element certain amount of times.
Copied!
Parameters:
Name
Type
Description
locator
String|Element
Element locator.
taps
Number
Number of taps.
timeout
Number
optional Timeout in milliseconds. Default is 60 seconds.
Supported On:

closeApp

Closes the currently open app.
Usage example:
1
mob.init(caps); // Starts a mobile session and opens app from desired capabilities
2
mob.launchApp(); // Launch the app.
3
mob.closeApp(); // Close the app.
Copied!
Supported On:

debug

Stop test execution and allow interactive command execution (REPL).
Usage example:
1
mob.init();
2
mob.open("www.yourwebsite.com");
3
mob.debug();
Copied!
Supported On:

dispose

Ends the current session.
Parameters:
Name
Type
Description
status
String
optional Test status, either passed or failed.

dragAndDrop

Tap on an element, drag by the specified offset, and release.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.dragAndDrop("id=Mark",-80,100);// Tap on an element, drag by the specified offset, and release.
Copied!
Parameters:
Name
Type
Description
locator
String|Element
Element locator on which to perform the initial tap.
xoffset
Number
Horizontal offset. Positive for right direction; Negative for left.
yoffset
Number
Vertical offset. Positive for down direction; Negative for up.
timeout
Number
optional Timeout in milliseconds. Default is 60 seconds.
Supported On:

enableNetwork

Enable or disable wifi or data.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.enableNetwork(true,false);//Enable wifi and disable data.
Copied!
Parameters:
Name
Type
Description
wifi
Boolean
Enable (true) or disable (false) wifi.
data
Boolean
Enable (true) or disable (false) data.
Supported On:

execute

Executes JavaScript in the context of the currently selected frame or window.
If return value is null or there is no return value, null is returned.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.execute(function(){
3
angular.element("#closeBtn").trigger('ng-click').click()
4
});//Executes / injects a javascript functions.
Copied!
Parameters:
Name
Type
Description
script
String|Function
The JavaScript to execute.
arg
...Object
optional Optional arguments to be passed to the JavaScript function.
Returns:
Object - The return value.
Supported On:

findElement

Finds an element.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
var el = mob.findElement("id=Password");
3
mob.click(el);
Copied!
Parameters:
Name
Type
Description
locator
String
Element locator.
parent
Element
optional Optional parent element for relative search.
timeout
Number
optional Timeout in milliseconds. Default is 60 seconds.
Returns:
Element - A Element object.
Supported On:

findElements

Finds elements.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
var els = mob.findElements("//div");
3
for (let el of els) {
4
var text = mob.getText(el);
5
log.info(text);
6
}
Copied!
Parameters:
Name
Type
Description
locator
String
Element locator.
parent
Element
optional Optional parent element for relative search.
timeout
Number
optional Timeout in milliseconds. Default is 60 seconds.
Returns:
Array.<Element> - Collection of Element objects.
Supported On:

getAlertText

Gets the text displayed by an alert or confirm dialog.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.click("id=Submit");// Clicks an element and opens an alert.
3
var a = mob.getAlertText();//Gets alert text.
Copied!
Returns:
String - Alert's text.
Supported On:

getAppiumLogs

Collects logs from the Appium server.
Usage example:
1
mob.init(caps); //Starts a mobile session and opens app from desired capabilities
2
mob.getAppiumLogs(); //Collects logs from the Appium server
Copied!
Returns:
Array.<Object> - A list of logs.
Supported On:

getBrowserLogs

Collects browser logs from the mobile device.
Usage example:
1
mob.init(caps); //Starts a mobile session and opens app from desired capabilities
2
mob.getBrowserLogs(); //Collects logs from the browser console
Copied!
Returns:
Array.<Object> - A list of logs.
Supported On:

getCapabilities

Returns currently defined capabilities.
Returns:
Object - Current capabilities object.

getCurrentActivity

Gets current Android app's activity name.
Usage example:
1
mob.init(caps); // Starts a mobile session and opens app from desired capabilities
2
let activity = mob.getCurrentActivity(); // Gets current Android activity.
Copied!
Supported On:

getCurrentPackage

Gets current Android app's package name.
Usage example:
1
mob.init(caps); // Starts a mobile session and opens app from desired capabilities
2
let package = mob.getCurrentPackage(); // Gets current Android package.
Copied!
Supported On:

getDeviceLogs

Collects logs from the mobile device.
Usage example:
1
mob.init(caps); //Starts a mobile session and opens app from desired capabilities
2
mob.getDeviceLogs(); //Collects logs from the mobile device
Copied!
Returns:
Array.<Object> - A list of logs.
Supported On:

getDeviceTime

Gets the time on the device.
Usage example:
1
mob.init(caps); //Starts a mobile session and opens app from desired capabilities
2
mob.getDeviceTime(); //Gets the device time
Copied!
Returns:
String - Time.
Supported On:

getDriver

Returns the underlying WDIO driver.
Returns:
Object - WDIO driver.

getLocation

Get element's location.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
var loc = mob.getLocation("id=element");//Get element's location.
3
var x = loc.x;
4
var y = loc.y;
Copied!
Parameters:
Name
Type
Description
locator
String|Element
Element locator.
timeout
Number
optional Timeout in milliseconds. Default is 60 seconds.
Returns:
Object - X and Y location of the element relative to top-left page corner.
Supported On:

getSource

Gets the source code of the page.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
var a = mob.getSource();//Gets the source code of the page.
Copied!
Returns:
String - HTML in case of web or hybrid application or XML in case of native.
Supported On:

getText

Returns the text (rendered text shown to the user; whitespace-trimmed) of an element.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
var a = mob.getText("id=TextArea");//Gets the text from an element.
Copied!
Parameters:
Name
Type
Description
locator
String|Element
Element locator.
timeout
Number
optional Timeout in milliseconds. Default is 60 seconds.
Returns:
String - Element's text.
Supported On:

getTitle

Returns the title of the currently active window.
Returns:
String - The page title.
Supported On:

getUrl

Gets the URL of the currently active window.
Usage example:
1
mob.init();//Opens browser session.
2
mob.open("www.yourwebsite.com");// Opens a website.
3
mob.getUrl();//Gets the url from the current page.
Copied!
Returns:
String - The page URL.
Supported On:

getValue

Gets element's value (whitespace-trimmed).
Usage example:
1
mob.init(caps);
2
var a = mob.getValue("id=ValueArea");//Gets the value from an element.
Copied!
Parameters:
Name
Type
Description
locator
String|Element
Element locator.
timeout
Number
optional Timeout in milliseconds. Default is 60 seconds.
Returns:
String - Element's value.
Supported On:

getWindowHandles

Gets handles of currently open windows.
Usage example:
1
mob.init();// Starts a mobile session.
2
mob.open("www.yourwebsite.com");// Opens a website.
3
mob.getWindowHandles();//Gets the window handles of currently open windows.
Copied!
Returns:
Array.<String> - Array of all available window handles.
Supported On:

hideKeyboard

Hides device keyboard.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.type("id=Password", "Password");//Types a password to a field.
3
mob.hideKeyboard("pressKey", "Done");//Hides device keyboard.
Copied!
Parameters:
Name
Type
Description
strategy
String
optional Strategy to use for closing the keyboard - 'press', 'pressKey', 'swipeDown', 'tapOut', 'tapOutside', 'default'.
key
String
optional Key value if strategy is 'pressKey'.
keyCode
String
optional Key code if strategy is 'pressKey'.
keyName
String
optional Key name if strategy is 'pressKey'.
Supported On:

init

Initializes a new Appium session.
Parameters:
Name
Type
Description
caps
String
optional Desired capabilities. If not specified capabilities will be taken from suite definition.
appiumUrl
String
optional Remote Appium server URL (default: http://localhost:4723/wd/hub).

installApp

Install an app on the remote device.
Usage example:
1
mob.init(caps); // Starts a mobile session and opens app from desired capabilities
2
mob.installApp('/mylocalappfile.apk'); // Install the app.
Copied!
Parameters:
Name
Type
Description
appLocalPath
String
The local file path to APK or IPA file.
Supported On:

isAppInstalled

Determines if an app is installed on the device.
Usage example:
1
mob.init(caps); //Starts a mobile session and opens app from desired capabilities
2
let installed = mob.isAppInstalled('com.android.calculator2'); // Determines if calculator app is installed.
Copied!
Parameters:
Name
Type
Description
app
String
App's ID.
Supported On:

isCheckable

Determines if checkbox or radio element is checkable.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.isCheckable("id=checkBox");//Determines if checkbox or radio element is checkable.
Copied!
Parameters:
Name
Type
Description
locator
String|Element
Element locator.
timeout
Number
optional Timeout in milliseconds. Default is 60 seconds.
Returns:
Boolean - true if element is checkable. false otherwise.
Supported On:

isChecked

Determines if checkbox or radio element is checked.
Usage example:
1
mob.init(caps);//Starts a mobile session and opens app from desired capabilities
2
mob.isChecked("id=checkBox");//Determines if checkbox or radio element is checked.
Copied!
Parameters:
Name
Type
Description
locator
String|Element
Element locator.
timeout
Number
optional Timeout in milliseconds. Default is 60 seconds.
Returns:
Boolean - true if element is checked. false otherwise.
Supported On: