swipe
Last updated
Was this helpful?
Last updated
Was this helpful?
This command allows you to mimic movement across a touch screen. This is useful for swiping components such as cards, carousels and bottom sheets.
Note: to move around a screen, you may prefer the command.
For simple swipes, simply pass a direction:
⬆️ UP
- swipes up from the centre of the screen to the top of the screen.
⬇️ DOWN
- swipes down from the centre of the screen to the bottom of the screen
⬅️ LEFT
- swipes from right to left of the screen
➡️ RIGHT
- swipes from left to right of the screen
For example:
By default, the test runner will perform the swipe over 400 ms. That's the time it takes to get from start to end.
However, you may specify a custom speed (in milliseconds) using the duration command. For example, if you wanted to test a slow 2-second swipe:
If you need more control, you can tell the runner to use specific coordinates.
For example, with percentage-based coordinates:
Or using pixel-based coordinates:
NB: avoid pixel-based if possible as they don't translate to other screen sizes/viewports
If you need to target a specific view or component with your swipe command, then you can specify a starting using the from
option.
For example, paired with the :
Or with the :