Skip to content
Branch: master
Find file Copy path
Find file Copy path
16 contributors

Users who have contributed to this file

@LeoNatan @rotemmiz @leotm @DmitryPonomarenko @yurtaev @yedidyak @smrpr @reimertz @osikes @michaelgmcd @sraikimaxime @isnifer @jhen0409 @matthewrfindley @DanielMSchmidt @paveltar
169 lines (121 sloc) 5.17 KB

Actions on Element

Detox uses Matchers to find UI elements in your app, Actions to emulate user interaction with those elements and Expectations to verify values on those elements.


Actions are functions that emulate user behavior. They are being performed on matched elements.



Simulates a tap on an element.

await element('tappable')).tap();


Simulates a long press on an element. duration - long press time interval. (iOS only)

await element('tappable')).longPress();


Simulates multiple taps on an element.

await element('tappable')).multiTap(3);


Simulates a tap at a specific point on an element.

Note: The point coordinates are relative to the matched element and the element size could changes on different devices or even when changing the device font size.

await element('tappable')).tapAtPoint({x:5, y:10});


Taps the backspace key on the built-in keyboard.

await element('textField')).tapBackspaceKey();


Taps the return key on the built-in keyboard.

await element('textField')).tapReturnKey();


Uses the builtin keyboard to type text into a text field.

await element('textField')).typeText('passcode');


Pastes text into a text field.

await element('textField')).replaceText('passcode again');


Clears text from a text field.

await element('textField')).clearText();

scroll(pixels, direction, startPositionX=NaN, startPositionY=NaN)

Scrolls a given amount of pixels in the provided direction, starting from the provided start positions. pixels - independent device pixels direction - left/right/up/down startPositionX - the X starting scroll position, in percentage; valid input: [0.0, 1.0], NaN; default: NaN—choose the best value automatically startPositionY - the Y starting scroll position, in percentage; valid input: [0.0, 1.0], NaN; default: NaN—choose the best value automatically

await element('scrollView')).scroll(100, 'down', NaN, 0.85);
await element('scrollView')).scroll(100, 'up');


Scrolls to the provided edge.

edge - left/right/top/bottom

await element('scrollView')).scrollTo('bottom');
await element('scrollView')).scrollTo('top');

swipe(direction, speed, percentage)

Swipes in the provided direction at the provided speed, started from percentage.

direction - left/right/up/down speed - fast/slow - default is fast percentage - (optional) screen percentage to swipe; valid input: [0.0, 1.0]

await element('scrollView')).swipe('down');
await element('scrollView')).swipe('down', 'fast');
await element('scrollView')).swipe('down', 'fast', 0.5);

setColumnToValue(column, value) iOS only

Sets a picker view’s column to the given value. This function supports both date pickers and general picker views.

column - date picker column index value - string value to set in column

await expect(element('pickerView'))).toBeVisible();
await element('pickerView')).setColumnToValue(1,"6");
await element('pickerView')).setColumnToValue(2,"34");

Note: When working with date pickers, you should always set an explicit locale when launching your app in order to prevent flakiness from different date and time styles. See here for more information.

setDatePickerDate(dateString, dateFormat) iOS only

Sets the date of a date picker to a date generated from the provided string and date format.

dateString - string representing a date in the supplied dateFormat dateFormat - format for the dateString supplied

await expect(element('datePicker'))).toBeVisible();
await element('datePicker')).setDatePickerDate('2019-02-06T05:10:00-08:00', "yyyy-MM-dd'T'HH:mm:ssZZZZZ");

pinchWithAngle(direction, speed, angle) iOS only

Pinches in the given direction with speed and angle.

direction - inward/outward speed - slow/fast - default is slow angle - value in radiant - default is 0

await expect(element('PinchableScrollView'))).toBeVisible();
await element('PinchableScrollView')).pinchWithAngle('outward', 'slow', 0);
You can’t perform that action at this time.