/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:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.click("id=Submit");// Clicks an element and opens an alert.mob.alertAccept();//Automatically press on 'OK' button in the alert pop-up.
alertDismiss
Dismisses an alert or a confirmation dialog.
In case of an alert box this command is identical to alertAccept.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.click("id=Submit");// Clicks an element and opens an alert.mob.alertDismiss();//Automatically press on 'Cancel' button in the alert pop-up.
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:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.click("id=Submit");// Clicks an element and opens an alert.mob.assertAlert("Your Alert's text");//Asserts the alert's text.
Parameters:
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:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.assertText("id=UserName","John Doe");// Asserts if an element’s text is as expected.
Parameters:
assertTitle
Asserts the page title.
Assertion pattern can be any of the supported string matching patterns(on the top of page).
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.assertTitle("Your websites title!");// Asserts if the title of the page.
Parameters:
assertValue
Asserts element's value.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.assertValue("id=UserName","John Doe");// Asserts if the value of an element.
Parameters:
back
Navigate backwards in the browser history or simulates back button on Android device.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.click("id=NextPage);// Clicks an element and opens an alert.mob.back();//Navigate back to previous page.
clear
Clears element's value or content
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.type("id=Password","Password");//Types a password to a field.mob.clear("id=Password");//Clears the characters from the field of an element.
Parameters:
click
Clicks on an element.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.click("id=Submit");// Clicks an element.
Parameters:
clickHidden
Clicks on a non-visible element.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.clickHidden("id=hiddenContent);// Clicks an hidden element.
Parameters:
clickLong
Performs a long click/touch on an element.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.clickLong("id=Mark",6000);// Clicks an element for a certain duration.
Parameters:
clickMultipleTimes
Performs tap on an element multiple times in quick succession.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.clickMultipleTimes("id=Mark",4);// Clicks an element certain amount of times.
Parameters:
closeApp
Closes the currently open app.
** Usage example:**
mob.init(caps); // Starts a mobile session and opens app from desired capabilitiesmob.launchApp(); // Launch the app.mob.closeApp(); // Close the app.
debug
Stop test execution and allow interactive command execution (REPL).
Tap on an element, drag by the specified offset, and release.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.dragAndDrop("id=Mark",-80,100);// Tap on an element, drag by the specified offset, and release.
Parameters:
enableNetwork
Enable or disable wifi or data.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.enableNetwork(true,false);//Enable wifi and disable data.
Parameters:
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:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.execute(function(){angular.element("#closeBtn").trigger('ng-click').click()});//Executes / injects a javascript functions.
Parameters:
Returns:
Object - The return value.
findElement
Finds an element.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesvar el =mob.findElement("id=Password");mob.click(el);
Parameters:
Returns:
Element - A Element object.
findElements
Finds elements.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesvar els =mob.findElements("//div");for (let el of els) {var text =mob.getText(el);log.info(text);}
Parameters:
Returns:
Array.<Element> - Collection of Element objects.
getAlertText
Gets the text displayed by an alert or confirm dialog.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.click("id=Submit");// Clicks an element and opens an alert.var a =mob.getAlertText();//Gets alert text.
Returns:
String - Alert's text.
getAppiumLogs
Collects logs from the Appium server.
** Usage example:**
mob.init(caps); //Starts a mobile session and opens app from desired capabilitiesmob.getAppiumLogs(); //Collects logs from the Appium server
Returns:
Array.<Object> - A list of logs.
getBrowserLogs
Collects browser logs from the mobile device.
** Usage example:**
mob.init(caps); //Starts a mobile session and opens app from desired capabilitiesmob.getBrowserLogs(); //Collects logs from the browser console
Returns:
Array.<Object> - A list of logs.
getCapabilities
Returns currently defined capabilities.
Returns:
Object - Current capabilities object.
getCurrentActivity
Gets current Android app's activity name.
** Usage example:**
mob.init(caps); // Starts a mobile session and opens app from desired capabilitieslet activity =mob.getCurrentActivity(); // Gets current Android activity.
getCurrentPackage
Gets current Android app's package name.
** Usage example:**
mob.init(caps); // Starts a mobile session and opens app from desired capabilitieslet package =mob.getCurrentPackage(); // Gets current Android package.
getDeviceLogs
Collects logs from the mobile device.
** Usage example:**
mob.init(caps); //Starts a mobile session and opens app from desired capabilitiesmob.getDeviceLogs(); //Collects logs from the mobile device
Returns:
Array.<Object> - A list of logs.
getDeviceTime
Gets the time on the device.
** Usage example:**
mob.init(caps); //Starts a mobile session and opens app from desired capabilitiesmob.getDeviceTime(); //Gets the device time
Returns:
String - Time.
getDriver
Returns the underlying WDIO driver.
Returns:
Object - WDIO driver.
getLocation
Get element's location.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesvar loc =mob.getLocation("id=element");//Get element's location.var x =loc.x;var y =loc.y;
Parameters:
Returns:
Object - X and Y location of the element relative to top-left page corner.
getSource
Gets the source code of the page.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesvar a =mob.getSource();//Gets the source code of the page.
Returns:
String - HTML in case of web or hybrid application or XML in case of native.
getText
Returns the text (rendered text shown to the user; whitespace-trimmed) of an element.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesvar a =mob.getText("id=TextArea");//Gets the text from an element.
Parameters:
Returns:
String - Element's text.
getTitle
Returns the title of the currently active window.
Returns:
String - The page title.
getUrl
Gets the URL of the currently active window.
** Usage example:**
mob.init();//Opens browser session.mob.open("www.yourwebsite.com");// Opens a website.mob.getUrl();//Gets the url from the current page.
Returns:
String - The page URL.
getValue
Gets element's value (whitespace-trimmed).
** Usage example:**
mob.init(caps);var a =mob.getValue("id=ValueArea");//Gets the value from an element.
Parameters:
Returns:
String - Element's value.
getWindowHandles
Gets handles of currently open windows.
** Usage example:**
mob.init();// Starts a mobile session.mob.open("www.yourwebsite.com");// Opens a website.mob.getWindowHandles();//Gets the window handles of currently open windows.
Returns:
Array.<String> - Array of all available window handles.
hideKeyboard
Hides device keyboard.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.type("id=Password","Password");//Types a password to a field.mob.hideKeyboard("pressKey","Done");//Hides device keyboard.
Parameters:
init
Initializes a new Appium session.
Parameters:
installApp
Install an app on the remote device.
** Usage example:**
mob.init(caps); // Starts a mobile session and opens app from desired capabilitiesmob.installApp('/mylocalappfile.apk'); // Install the app.
Parameters:
isAppInstalled
Determines if an app is installed on the device.
** Usage example:**
mob.init(caps); //Starts a mobile session and opens app from desired capabilitieslet installed =mob.isAppInstalled('com.android.calculator2'); // Determines if calculator app is installed.
Parameters:
isCheckable
Determines if checkbox or radio element is checkable.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.isCheckable("id=checkBox");//Determines if checkbox or radio element is checkable.
Parameters:
Returns:
Boolean - true if element is checkable. false otherwise.
isChecked
Determines if checkbox or radio element is checked.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.isChecked("id=checkBox");//Determines if checkbox or radio element is checked.
Parameters:
Returns:
Boolean - true if element is checked. false otherwise.
isClickable
Determines if an element is clickable.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.isClickable("id=Element");//Determines if element is clickable.
Parameters:
Returns:
Boolean - true if element is clickable. false otherwise.
isExist
Wait for an element to become available.
The element is not necessary needs to be visible.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.isExist("id=Element");//Determines if element exists.
Parameters:
Returns:
Boolean - true if the element exists. false otherwise.
isSelected
Determines if an element is selected.
** Usage example:**
mob.init(caps);var a =mob.isSelected("id=Selection");if (a) {...} else {...}
Parameters:
Returns:
Boolean - true if element is selected. false otherwise.
isVisible
Checks if element is present and visible. Returns false if element was not found or wasn't visible within the specified timeout.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.isVisible("id=Selection");//Determines if element is visible.
Parameters:
Returns:
Boolean - True if element was found and it was visible. False otherwise.
isWebViewContext
Checks if the current context is of WebView type.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.isWebViewContext();//Checks if the current context is of WebView type.
Returns:
Boolean - true if the context name is WEBVIEW or CHROMIUM.
launchApp
Launches the app defined in the current session's capabilities.
** Usage example:**
mob.init(caps); // Starts a mobile session and opens app from desired capabilitiesmob.launchApp(); // Launch the app defined in the session's capabilities.
longPressKeyCode
Press and hold a particular key code on the device.
** Usage example:**
https://developer.android.com/reference/android/view/KeyEvent.html - list of key codesmob.init();//Starts a mobile sessionmob.open('https://keycode.info/');mob.longPressKeyCode(32);// 32 - d key
Parameters:
open
Opens an URL.
The open command waits for the page to load before proceeding.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.open('www.yourwebsite.com');//Opens an URL.
Parameters:
pause
Pause test execution for the given amount of milliseconds.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.pause(10*1000);//Pauses the execution for 10 seconds (10000ms)
Parameters:
removeApp
Remove an app from the device.
** Usage example:**
mob.init(caps); // Starts a mobile session and opens app from desired capabilitiesmob.removeApp('com.android.calculator2'); // Remove the calculator app from the device.
Parameters:
resetApp
Reset the currently running app's state (e.g. local settings) on the device.
** Usage example:**
mob.init(caps); // Starts a mobile session and opens app from desired capabilitiesmob.resetApp(); // Reset curently running app
scrollIntoElement
Scrolls the view element until a specified target element inside the view is found.
** Usage example:**
mob.init(caps);//Starts a mobile session and opens app from desired capabilitiesmob.scrollIntoElement('id=bottomPanel','id=Button',0,30,50);//Scrolls the view element until a specified target element inside the view is found.
Parameters:
scrollIntoView
Scrolls the page or a container element to the location of the specified element.
** Usage example:**
mob.scrollIntoView('id=bottomPanel',true);// ormob.scrollIntoView('id=bottomPanel', { behavior:'auto',// Optional. Defines the transition animation: `auto` or `smooth`. Defaults to `auto`. block:'start',