Appium
Appium
Section titled “Appium”Extends Webdriver
Appium helper extends Webdriver helper. It supports all browser methods and also includes special methods for mobile apps testing. You can use this helper to test Web on desktop and mobile devices and mobile apps.
Appium Installation
Section titled “Appium Installation”Appium is an open source test automation framework for use with native, hybrid and mobile web apps that implements the WebDriver protocol. It allows you to run Selenium tests on mobile devices and also test native, hybrid and mobile web apps.
Download and install Appium
npm install -g appiumLaunch the daemon: appium
Helper configuration
Section titled “Helper configuration”This helper should be configured in codecept.conf.ts or codecept.conf.js
appiumV2: set this to true if you want to run tests with AppiumV2. See more how to setup hereapp: Application path. Local path or remote URL to an .ipa or .apk file, or a .zip containing one of these. Alias to desiredCapabilities.appPackagehost: (default: ‘localhost’) Appium hostport: (default: ‘4723’) Appium portplatform: (Android or IOS), which mobile OS to use; alias to desiredCapabilities.platformNamerestart: restart browser or app between tests (default: true), if set to false cookies will be cleaned but browser window will be kept and for apps nothing will be changed.desiredCapabilities: [], Appium capabilities, see belowplatformName- Which mobile OS platform to useappPackage- Java package of the Android app you want to runappActivity- Activity name for the Android activity you want to launch from your package.deviceName: The kind of mobile device or emulator to useplatformVersion: Mobile OS versionapp- The absolute local path or remote http URL to an .ipa or .apk file, or a .zip containing one of these. Appium will attempt to install this app binary on the appropriate device first.browserName: Name of mobile web browser to automate. Should be an empty string if automating an app instead.
Example Android App:
{ helpers: { Appium: { platform: "Android", desiredCapabilities: { appPackage: "com.example.android.myApp", appActivity: "MainActivity", deviceName: "OnePlus3", platformVersion: "6.0.1" } } }}Example iOS Mobile Web with local Appium:
{helpers: { Appium: { platform: "iOS", url: "https://the-internet.herokuapp.com/", desiredCapabilities: { deviceName: "iPhone X", platformVersion: "12.0", browserName: "safari" } }}}Example iOS Mobile Web on BrowserStack:
{helpers: { Appium: { host: "hub-cloud.browserstack.com", port: 4444, user: process.env.BROWSERSTACK_USER, key: process.env.BROWSERSTACK_KEY, platform: "iOS", url: "https://the-internet.herokuapp.com/", desiredCapabilities: { realMobile: "true", device: "iPhone 8", os_version: "12", browserName: "safari" } }}}Example Android App using AppiumV2 on BrowserStack:
{helpers: { Appium: { appiumV2: true, host: "hub-cloud.browserstack.com", port: 4444, user: process.env.BROWSERSTACK_USER, key: process.env.BROWSERSTACK_KEY, app: `bs://c700ce60cf1gjhgjh3ae8ed9770ghjg5a55b8e022f13c5827cg`, browser: '', desiredCapabilities: { 'appPackage': data.packageName, 'deviceName': process.env.DEVICE || 'Google Pixel 3', 'platformName': process.env.PLATFORM || 'android', 'platformVersion': process.env.OS_VERSION || '10.0', 'automationName': process.env.ENGINE || 'UIAutomator2', 'newCommandTimeout': 300000, 'androidDeviceReadyTimeout': 300000, 'androidInstallTimeout': 90000, 'appWaitDuration': 300000, 'autoGrantPermissions': true, 'gpsEnabled': true, 'isHeadless': false, 'noReset': false, 'noSign': true, 'bstack:options' : { "appiumVersion" : "2.0.1", }, } }}}Additional configuration params can be used from https://github.com/appium/appium/blob/master/packages/appium/docs/en/guides/caps.md
Access From Helpers
Section titled “Access From Helpers”Receive Appium client from a custom helper by accessing browser property:
let browser = this.helpers['Appium'].browserMethods
Section titled “Methods”Parameters
Section titled “Parameters”config
runOnIOS
Section titled “runOnIOS”Execute code only on iOS
I.runOnIOS(() => { I.click('//UIAApplication[1]/UIAWindow[1]/UIAButton[1]'); I.see('Hi, IOS', '~welcome');});Additional filter can be applied by checking for capabilities. For instance, this code will be executed only on iPhone 5s:
I.runOnIOS({deviceName: 'iPhone 5s'},() => { // ...});Also capabilities can be checked by a function.
I.runOnAndroid((caps) => { // caps is current config of desiredCapabiliites return caps.platformVersion >= 6},() => { // ...});Parameters
Section titled “Parameters”capsanyfnany
runOnAndroid
Section titled “runOnAndroid”Execute code only on Android
I.runOnAndroid(() => { I.click('io.selendroid.testapp:id/buttonTest');});Additional filter can be applied by checking for capabilities. For instance, this code will be executed only on Android 6.0:
I.runOnAndroid({platformVersion: '6.0'},() => { // ...});Also capabilities can be checked by a function. In this case, code will be executed only on Android >= 6.
I.runOnAndroid((caps) => { // caps is current config of desiredCapabiliites return caps.platformVersion >= 6},() => { // ...});Parameters
Section titled “Parameters”capsanyfnany
runInWeb
Section titled “runInWeb”Execute code only in Web mode.
I.runInWeb(() => { I.waitForElement('#data'); I.seeInCurrentUrl('/data');});checkIfAppIsInstalled
Section titled “checkIfAppIsInstalled”Returns app installation status.
I.checkIfAppIsInstalled("com.example.android.apis");Parameters
Section titled “Parameters”bundleIdstring String ID of bundled app
Returns Promise<boolean> Appium: support only Android
seeAppIsInstalled
Section titled “seeAppIsInstalled”Check if an app is installed.
I.seeAppIsInstalled("com.example.android.apis");Parameters
Section titled “Parameters”bundleIdstring String ID of bundled app
Returns Promise<void> Appium: support only Android
seeAppIsNotInstalled
Section titled “seeAppIsNotInstalled”Check if an app is not installed.
I.seeAppIsNotInstalled("com.example.android.apis");Parameters
Section titled “Parameters”bundleIdstring String ID of bundled app
Returns Promise<void> Appium: support only Android
installApp
Section titled “installApp”Install an app on device.
I.installApp('/path/to/file.apk');Parameters
Section titled “Parameters”pathstring path to apk file
Returns Promise<void> Appium: support only Android
removeApp
Section titled “removeApp”Remove an app from the device.
I.removeApp('appName', 'com.example.android.apis');Appium: support only Android
Parameters
Section titled “Parameters”resetApp
Section titled “resetApp”Reset the currently running app for current session.
I.resetApp();seeCurrentActivityIs
Section titled “seeCurrentActivityIs”Check current activity on an Android device.
I.seeCurrentActivityIs(".HomeScreenActivity")Parameters
Section titled “Parameters”currentActivitystring
Returns Promise<void> Appium: support only Android
seeDeviceIsLocked
Section titled “seeDeviceIsLocked”Check whether the device is locked.
I.seeDeviceIsLocked();Returns Promise<void> Appium: support only Android
seeDeviceIsUnlocked
Section titled “seeDeviceIsUnlocked”Check whether the device is not locked.
I.seeDeviceIsUnlocked();Returns Promise<void> Appium: support only Android
seeOrientationIs
Section titled “seeOrientationIs”Check the device orientation
I.seeOrientationIs('PORTRAIT');I.seeOrientationIs('LANDSCAPE')Parameters
Section titled “Parameters”orientation("LANDSCAPE"|"PORTRAIT") LANDSCAPE or PORTRAITAppium: support Android and iOS
Returns Promise<void>
setOrientation
Section titled “setOrientation”Set a device orientation. Will fail, if app will not set orientation
I.setOrientation('PORTRAIT');I.setOrientation('LANDSCAPE')Parameters
Section titled “Parameters”orientation("LANDSCAPE"|"PORTRAIT") LANDSCAPE or PORTRAITAppium: support Android and iOS
grabAllContexts
Section titled “grabAllContexts”Get list of all available contexts
let contexts = await I.grabAllContexts();Returns Promise<Array<string>> Appium: support Android and iOS
grabContext
Section titled “grabContext”Retrieve current context
let context = await I.grabContext();Returns Promise<(string | null)> Appium: support Android and iOS
grabCurrentActivity
Section titled “grabCurrentActivity”Get current device activity.
let activity = await I.grabCurrentActivity();Returns Promise<string> Appium: support only Android
grabNetworkConnection
Section titled “grabNetworkConnection”Get information about the current network connection (Data/WIFI/Airplane). The actual server value will be a number. However WebdriverIO additional properties to the response object to allow easier assertions.
let con = await I.grabNetworkConnection();Returns Promise<{}> Appium: support only Android
grabOrientation
Section titled “grabOrientation”Get current orientation.
let orientation = await I.grabOrientation();Returns Promise<string> Appium: support Android and iOS
grabSettings
Section titled “grabSettings”Get all the currently specified settings.
let settings = await I.grabSettings();Returns Promise<string> Appium: support Android and iOS
switchToContext
Section titled “switchToContext”Switch to the specified context.
Parameters
Section titled “Parameters”contextany the context to switch to
switchToWeb
Section titled “switchToWeb”Switches to web context. If no context is provided switches to the first detected web context
// switch to first web contextI.switchToWeb();
// or set the context explicitlyI.switchToWeb('WEBVIEW_io.selendroid.testapp');Parameters
Section titled “Parameters”contextstring?
Returns Promise<void>
switchToNative
Section titled “switchToNative”Switches to native context. By default switches to NATIVE_APP context unless other specified.
I.switchToNative();
// or set context explicitlyI.switchToNative('SOME_OTHER_CONTEXT');Parameters
Section titled “Parameters”contextany? (optional, defaultnull)
Returns Promise<void>
startActivity
Section titled “startActivity”Start an arbitrary Android activity during a session.
I.startActivity('io.selendroid.testapp', '.RegisterUserActivity');Appium: support only Android
Parameters
Section titled “Parameters”Returns Promise<void>
setNetworkConnection
Section titled “setNetworkConnection”Set network connection mode.
- airplane mode
- wifi mode
- data data
I.setNetworkConnection(0) // airplane mode off, wifi off, data offI.setNetworkConnection(1) // airplane mode on, wifi off, data offI.setNetworkConnection(2) // airplane mode off, wifi on, data offI.setNetworkConnection(4) // airplane mode off, wifi off, data onI.setNetworkConnection(6) // airplane mode off, wifi on, data onSee corresponding webdriverio reference.
Appium: support only Android
Parameters
Section titled “Parameters”valuenumber The network connection mode bitmask
setSettings
Section titled “setSettings”Update the current setting on the device
I.setSettings({cyberdelia: 'open'});Parameters
Section titled “Parameters”settingsobject objectAppium: support Android and iOS
hideDeviceKeyboard
Section titled “hideDeviceKeyboard”Hide the keyboard.
// taps outside to hide keyboard per defaultI.hideDeviceKeyboard();I.hideDeviceKeyboard('tapOutside');
// or by pressing keyI.hideDeviceKeyboard('pressKey', 'Done');Appium: support Android and iOS
Parameters
Section titled “Parameters”strategy("tapOutside"|"pressKey")? Desired strategy to close keyboard (‘tapOutside’ or ‘pressKey’)keystring? Optional key
sendDeviceKeyEvent
Section titled “sendDeviceKeyEvent”Send a key event to the device. List of keys: https://developer.android.com/reference/android/view/KeyEvent.html
I.sendDeviceKeyEvent(3);Parameters
Section titled “Parameters”keyValuenumber Device specific key value
Returns Promise<void> Appium: support only Android
openNotifications
Section titled “openNotifications”Open the notifications panel on the device.
I.openNotifications();Returns Promise<void> Appium: support only Android
makeTouchAction
Section titled “makeTouchAction”The Touch Action API provides the basis of all gestures that can be automated in Appium. At its core is the ability to chain together ad hoc individual actions, which will then be applied to an element in the application on the device. See complete documentation
I.makeTouchAction("~buttonStartWebviewCD", 'tap');Parameters
Section titled “Parameters”locatoraction
Returns Promise<void> Appium: support Android and iOS
Taps on element.
I.tap("~buttonStartWebviewCD");Shortcut for makeTouchAction
Parameters
Section titled “Parameters”locatorany
Returns Promise<void>
Perform a swipe on the screen or an element.
let locator = "#io.selendroid.testapp:id/LinearLayout1";I.swipe(locator, 800, 1200, 1000);Parameters
Section titled “Parameters”locator(string | object)xoffsetnumberyoffsetnumberspeednumber (optional), 1000 by default (optional, default1000)
Returns Promise<void> Appium: support Android and iOS
performSwipe
Section titled “performSwipe”Perform a swipe on the screen.
I.performSwipe({ x: 300, y: 100 }, { x: 200, y: 100 });Parameters
Section titled “Parameters”swipeDown
Section titled “swipeDown”Perform a swipe down on an element.
let locator = "#io.selendroid.testapp:id/LinearLayout1";I.swipeDown(locator); // simple swipeI.swipeDown(locator, 500); // set speedI.swipeDown(locator, 1200, 1000); // set offset and speedParameters
Section titled “Parameters”locator(string | object)yoffsetnumber? (optional) (optional, default1000)speednumber (optional), 1000 by default (optional, default1000)
Returns Promise<void> Appium: support Android and iOS
swipeLeft
Section titled “swipeLeft”Perform a swipe left on an element.
let locator = "#io.selendroid.testapp:id/LinearLayout1";I.swipeLeft(locator); // simple swipeI.swipeLeft(locator, 500); // set speedI.swipeLeft(locator, 1200, 1000); // set offset and speedParameters
Section titled “Parameters”locator(string | object)xoffsetnumber? (optional) (optional, default1000)speednumber (optional), 1000 by default (optional, default1000)
Returns Promise<void> Appium: support Android and iOS
swipeRight
Section titled “swipeRight”Perform a swipe right on an element.
let locator = "#io.selendroid.testapp:id/LinearLayout1";I.swipeRight(locator); // simple swipeI.swipeRight(locator, 500); // set speedI.swipeRight(locator, 1200, 1000); // set offset and speedParameters
Section titled “Parameters”locator(string | object)xoffsetnumber? (optional) (optional, default1000)speednumber (optional), 1000 by default (optional, default1000)
Returns Promise<void> Appium: support Android and iOS
swipeUp
Section titled “swipeUp”Perform a swipe up on an element.
let locator = "#io.selendroid.testapp:id/LinearLayout1";I.swipeUp(locator); // simple swipeI.swipeUp(locator, 500); // set speedI.swipeUp(locator, 1200, 1000); // set offset and speedParameters
Section titled “Parameters”locator(string | object)yoffsetnumber? (optional) (optional, default1000)speednumber (optional), 1000 by default (optional, default1000)
Returns Promise<void> Appium: support Android and iOS
swipeTo
Section titled “swipeTo”Perform a swipe in selected direction on an element to searchable element.
I.swipeTo( "android.widget.CheckBox", // searchable element "//android.widget.ScrollView/android.widget.LinearLayout", // scroll element "up", // direction 30, 100, 500);Parameters
Section titled “Parameters”searchableLocatorstringscrollLocatorstringdirectionstringtimeoutnumberoffsetnumberspeednumber
Returns Promise<void> Appium: support Android and iOS
touchPerform
Section titled “touchPerform”Performs a specific touch action. The action object need to contain the action name, x/y coordinates
I.touchPerform([{ action: 'press', options: { x: 100, y: 200 }}, {action: 'release'}])
I.touchPerform([{ action: 'tap', options: { element: '1', // json web element was queried before x: 10, // x offset y: 20, // y offset count: 1 // number of touches }}]);Appium: support Android and iOS
Parameters
Section titled “Parameters”actionsArray Array of touch actions
pullFile
Section titled “pullFile”Pulls a file from the device.
I.pullFile('/storage/emulated/0/DCIM/logo.png', 'my/path');// save file to output dirI.pullFile('/storage/emulated/0/DCIM/logo.png', output_dir);Parameters
Section titled “Parameters”Returns Promise<string> Appium: support Android and iOS
shakeDevice
Section titled “shakeDevice”Perform a shake action on the device.
I.shakeDevice();Returns Promise<void> Appium: support only iOS
rotate
Section titled “rotate”Perform a rotation gesture centered on the specified element.
I.rotate(120, 120)See corresponding webdriverio reference.
Parameters
Section titled “Parameters”xydurationradiusrotationtouchCount
Returns Promise<void> Appium: support only iOS
setImmediateValue
Section titled “setImmediateValue”Set immediate value in app.
See corresponding webdriverio reference.
Parameters
Section titled “Parameters”idvalue
Returns Promise<void> Appium: support only iOS
simulateTouchId
Section titled “simulateTouchId”Simulate Touch ID with either valid (match == true) or invalid (match == false) fingerprint.
I.touchId(); // simulates valid fingerprintI.touchId(true); // simulates valid fingerprintI.touchId(false); // simulates invalid fingerprintParameters
Section titled “Parameters”match
Returns Promise<void> Appium: support only iOS TODO: not tested
closeApp
Section titled “closeApp”Close the given application.
I.closeApp();Returns Promise<void> Appium: support both Android and iOS
appendField
Section titled “appendField”Appends text to a input field or textarea. Field is located by name, label, CSS or XPath
I.appendField('#myTextField', 'appended');// typing secretI.appendField('password', secret('123456'));Parameters
Section titled “Parameters”field(string | object) located by label|name|CSS|XPath|strict locatorvaluestring text value to append.
Returns void automatically synchronized promise through #recorder
checkOption
Section titled “checkOption”Selects a checkbox or radio button. Element is located by label or name or CSS or XPath.
The second parameter is a context (CSS or XPath locator) to narrow the search.
I.checkOption('#agree');I.checkOption('I Agree to Terms and Conditions');I.checkOption('agree', '//form');Parameters
Section titled “Parameters”field(string | object) checkbox located by label | name | CSS | XPath | strict locator.context(string? | object) (optional,nullby default) element located by CSS | XPath | strict locator. (optional, defaultnull)
Returns void automatically synchronized promise through #recorder
Perform a click on a link or a button, given by a locator. If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string. For buttons, the “value” attribute, “name” attribute, and inner text are searched. For links, the link text is searched. For images, the “alt” attribute and inner text of any parent links are searched.
The second parameter is a context (CSS or XPath locator) to narrow the search.
// simple linkI.click('Logout');// button of formI.click('Submit');// CSS buttonI.click('#form input[type=submit]');// XPathI.click('//form/*[@type=submit]');// link in contextI.click('Logout', '#nav');// using strict locatorI.click({css: 'nav a.login'});Parameters
Section titled “Parameters”locator(string | object) clickable link or button located by text, or any element located by CSS|XPath|strict locator.context(string? | object | null) (optional,nullby default) element to search in CSS|XPath|Strict locator. (optional, defaultnull)
Returns void automatically synchronized promise through #recorder
dontSeeCheckboxIsChecked
Section titled “dontSeeCheckboxIsChecked”Verifies that the specified checkbox is not checked.
I.dontSeeCheckboxIsChecked('#agree'); // located by IDI.dontSeeCheckboxIsChecked('I agree to terms'); // located by labelI.dontSeeCheckboxIsChecked('agree'); // located by nameParameters
Section titled “Parameters”Returns void automatically synchronized promise through #recorder
dontSeeElement
Section titled “dontSeeElement”Opposite to seeElement. Checks that element is not visible (or in DOM)
I.dontSeeElement('.modal'); // modal is not shownParameters
Section titled “Parameters”Returns void automatically synchronized promise through #recorder
dontSeeInField
Section titled “dontSeeInField”Checks that value of input field or textarea doesn’t equal to given value
Opposite to seeInField.
I.dontSeeInField('email', 'user@user.com'); // field by nameI.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSSParameters
Section titled “Parameters”field(string | object) located by label|name|CSS|XPath|strict locator.value(string | object) value to check.
Returns void automatically synchronized promise through #recorder
dontSee
Section titled “dontSee”Opposite to see. Checks that a text is not present on a page.
Use context parameter to narrow down the search.
I.dontSee('Login'); // assume we are already logged in.I.dontSee('Login', '.nav'); // no login inside .nav elementParameters
Section titled “Parameters”textstring which is not present.context(string | object)? (optional) element located by CSS|XPath|strict locator in which to perfrom search. (optional, defaultnull)
Returns void automatically synchronized promise through #recorder
fillField
Section titled “fillField”Fills a text field or textarea, after clearing its value, with the given string. Field is located by name, label, CSS, or XPath.
// by labelI.fillField('Email', 'hello@world.com');// by nameI.fillField('password', secret('123456'));// by CSSI.fillField('form#login input[name=username]', 'John');// or by strict locatorI.fillField({css: 'form#login input[name=username]'}, 'John');Parameters
Section titled “Parameters”field(string | object) located by label|name|CSS|XPath|strict locator.value(string | object) text value to fill.
Returns void automatically synchronized promise through #recorder
grabTextFromAll
Section titled “grabTextFromAll”Retrieves all texts from an element located by CSS or XPath and returns it to test.
Resumes test execution, so should be used inside async with await operator.
let pins = await I.grabTextFromAll('#pin li');Parameters
Section titled “Parameters”Returns Promise<Array<string>> attribute value
grabTextFrom
Section titled “grabTextFrom”Retrieves a text from an element located by CSS or XPath and returns it to test.
Resumes test execution, so should be used inside async with await operator.
let pin = await I.grabTextFrom('#pin');If multiple elements found returns first element.
Parameters
Section titled “Parameters”Returns Promise<string> attribute value
grabNumberOfVisibleElements
Section titled “grabNumberOfVisibleElements”Grab number of visible elements by locator.
Resumes test execution, so should be used inside async function with await operator.
let numOfElements = await I.grabNumberOfVisibleElements('p');Parameters
Section titled “Parameters”Returns Promise<number> number of visible elements
grabAttributeFrom
Section titled “grabAttributeFrom”Can be used for apps only with several values (“contentDescription”, “text”, “className”, “resourceId”)
Retrieves an attribute from an element located by CSS or XPath and returns it to test.
Resumes test execution, so should be used inside async with await operator.
If more than one element is found - attribute of first element is returned.
let hint = await I.grabAttributeFrom('#tooltip', 'title');Parameters
Section titled “Parameters”Returns Promise<string> attribute value
grabAttributeFromAll
Section titled “grabAttributeFromAll”Can be used for apps only with several values (“contentDescription”, “text”, “className”, “resourceId”)
Retrieves an array of attributes from elements located by CSS or XPath and returns it to test.
Resumes test execution, so should be used inside async with await operator.
let hints = await I.grabAttributeFromAll('.tooltip', 'title');Parameters
Section titled “Parameters”Returns Promise<Array<string>> attribute value
grabValueFromAll
Section titled “grabValueFromAll”Retrieves an array of value from a form located by CSS or XPath and returns it to test.
Resumes test execution, so should be used inside async function with await operator.
let inputs = await I.grabValueFromAll('//form/input');Parameters
Section titled “Parameters”Returns Promise<Array<string>> attribute value
grabValueFrom
Section titled “grabValueFrom”Retrieves a value from a form element located by CSS or XPath and returns it to test.
Resumes test execution, so should be used inside async function with await operator.
If more than one element is found - value of first element is returned.
let email = await I.grabValueFrom('input[name=email]');Parameters
Section titled “Parameters”Returns Promise<string> attribute value
saveScreenshot
Section titled “saveScreenshot”Saves a screenshot to ouput folder (set in codecept.conf.ts or codecept.conf.js). Filename is relative to output folder.
I.saveScreenshot('debug.png');Parameters
Section titled “Parameters”fileNamestring file name to save.
Returns Promise<void>
scrollIntoView
Section titled “scrollIntoView”Scroll element into viewport.
I.scrollIntoView('#submit');I.scrollIntoView('#submit', true);I.scrollIntoView('#submit', { behavior: "smooth", block: "center", inline: "center" });Parameters
Section titled “Parameters”locator(string | object) located by CSS|XPath|strict locator.scrollIntoViewOptions(ScrollIntoViewOptions | boolean) either alignToTop=true|false or scrollIntoViewOptions. See https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView.
Returns void automatically synchronized promise through #recorderSupported only for web testing
seeCheckboxIsChecked
Section titled “seeCheckboxIsChecked”Verifies that the specified checkbox is checked.
I.seeCheckboxIsChecked('Agree');I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to termsI.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});Parameters
Section titled “Parameters”Returns void automatically synchronized promise through #recorder
seeElement
Section titled “seeElement”Checks that a given Element is visible Element is located by CSS or XPath.
I.seeElement('#modal');Parameters
Section titled “Parameters”Returns void automatically synchronized promise through #recorder
seeInField
Section titled “seeInField”Checks that the given input field or textarea equals to given value. For fuzzy locators, fields are matched by label text, the “name” attribute, CSS, and XPath.
I.seeInField('Username', 'davert');I.seeInField({css: 'form textarea'},'Type your comment here');I.seeInField('form input[type=hidden]','hidden_value');I.seeInField('#searchform input','Search');Parameters
Section titled “Parameters”field(string | object) located by label|name|CSS|XPath|strict locator.value(string | object) value to check.
Returns void automatically synchronized promise through #recorder
Checks that a page contains a visible text. Use context parameter to narrow down the search.
I.see('Welcome'); // text welcome on a pageI.see('Welcome', '.content'); // text inside .content divI.see('Register', {css: 'form.register'}); // use strict locatorParameters
Section titled “Parameters”textstring expected on page.context(string? | object) (optional,nullby default) element located by CSS|Xpath|strict locator in which to search for text. (optional, defaultnull)
Returns void automatically synchronized promise through #recorder
selectOption
Section titled “selectOption”Selects an option in a drop-down select. Field is searched by label | name | CSS | XPath. Option is selected by visible text or by value.
I.selectOption('Choose Plan', 'Monthly'); // select by labelI.selectOption('subscription', 'Monthly'); // match option by textI.selectOption('subscription', '0'); // or by valueI.selectOption('//form/select[@name=account]','Premium');I.selectOption('form select[name=account]', 'Premium');I.selectOption({css: 'form select[name=account]'}, 'Premium');Provide an array for the second argument to select multiple options.
I.selectOption('Which OS do you use?', ['Android', 'iOS']);Parameters
Section titled “Parameters”select(string | object) field located by label|name|CSS|XPath|strict locator.option(string | Array<any>) visible text or value of option.
Returns void automatically synchronized promise through #recorderSupported only for web testing
waitForElement
Section titled “waitForElement”Waits for element to be present on page (by default waits for 1sec). Element can be located by CSS or XPath.
I.waitForElement('.btn.continue');I.waitForElement('.btn.continue', 5); // wait for 5 secsParameters
Section titled “Parameters”locator(string | object) element located by CSS|XPath|strict locator.secnumber? (optional,1by default) time in seconds to wait (optional, defaultnull)
Returns void automatically synchronized promise through #recorder
waitForVisible
Section titled “waitForVisible”Waits for an element to become visible on a page (by default waits for 1sec). Element can be located by CSS or XPath.
I.waitForVisible('#popup');Parameters
Section titled “Parameters”locator(string | object) element located by CSS|XPath|strict locator.secnumber (optional,1by default) time in seconds to wait (optional, default1)
Returns void automatically synchronized promise through #recorder
waitForInvisible
Section titled “waitForInvisible”Waits for an element to be removed or become invisible on a page (by default waits for 1sec). Element can be located by CSS or XPath.
I.waitForInvisible('#popup');Parameters
Section titled “Parameters”locator(string | object) element located by CSS|XPath|strict locator.secnumber (optional,1by default) time in seconds to wait (optional, default1)
Returns void automatically synchronized promise through #recorder
waitForText
Section titled “waitForText”Waits for a text to appear (by default waits for 1sec). Element can be located by CSS or XPath. Narrow down search results by providing context.
I.waitForText('Thank you, form has been submitted');I.waitForText('Thank you, form has been submitted', 5, '#modal');Parameters
Section titled “Parameters”textstring to wait for.secnumber (optional,1by default) time in seconds to wait (optional, default1)context(string | object)? (optional) element located by CSS|XPath|strict locator. (optional, defaultnull)
Returns void automatically synchronized promise through #recorder