# swipe

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 [scroll](/creating-tests/commands/scroll.md) command.

## Options

### Using the direction shortcut

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:

```yaml
- swipe:
    direction: DOWN
```

### Setting swipe speed

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:

```yaml
- swipe:
    direction: RIGHT
    duration: 2000
```

### Specifying start and end coordinates

If you need more control, you can tell the runner to use specific coordinates.

For example, with percentage-based coordinates:

```yaml
- swipe:
    start: 80%,80%  #bottom right
    end: 20%,20%    #top left
```

Or using pixel-based coordinates:

```yaml
- swipe:
    start: 400,220  #middle right
    end: 100,220    #middle left
```

*NB: avoid pixel-based if possible as they don't translate to other screen sizes/viewports*

### Specifying a start element using 'from'

If you need to target a specific view or component with your swipe command, then you can specify a starting [selector](/creating-tests/test-step-selectors.md) using the `from` option.

For example, paired with the [direction shortcut](#using-the-direction-shortcut):

```yaml
- swipe:
     from:
       text: "swipe from this text"
     direction: DOWN
```

Or with the [end coordinate](#specifying-start-and-end-coordinates):

```yaml
- swipe:
     from:
       text: "swipe from this text"
     end: 50%,10%
```

## Related Commands

[scroll](/creating-tests/commands/scroll.md)

[scrollUntilVisible](/creating-tests/commands/scrolluntilvisible.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.moropo.com/creating-tests/commands/swipe.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
