> ## Documentation Index
> Fetch the complete documentation index at: https://docs.quiesco.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Actions

> Tap, type, scroll, swipe and drag like a user, go back, and open deep links.

Actions do what a user does. In `native` mode (the default when the app has `@quiesco/native`) they are
real touches and keyboard input; in `js` mode they call the component's callbacks instead (see
[call options](https://docs.quiesco.dev/api.md#call-options)). Every action waits for the app to be idle before and after it, and
needs exactly one visible target ([finding elements](https://docs.quiesco.dev/api.md#finding-elements)).

Coordinates are logical units: points on iOS, dp on Android, CSS pixels on the web.

## Tapping

### `tap(target, options?)`

```ts theme={null}
tap(
  target: MatcherInput,
  options?: TapOptions,
): Promise<ElementSummary | undefined>
```

Types: [`MatcherInput`](./api-types#matcherinput) · [`TapOptions`](./api-types#tapoptions) · [`ElementSummary`](./api-types#elementsummary)

Taps the center of the element. An element partly cut off by a scroll view or an `overflow` ancestor is
tapped at the center of its visible part.

```ts theme={null}
await app.tap('save');

// a point inside the element, from its top-left corner
await app.tap('map', { point: { x: 40, y: 120 } });
```

| Option | Default | Meaning |
| - | - | - |
| `point` | the center | `{ x, y }` in the element's own coordinates, instead of its center |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the target and for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

### `doubleTap(target, options?)`

```ts theme={null}
doubleTap(
  target: MatcherInput,
  options?: ActionOptions,
): Promise<ElementSummary | undefined>
```

Types: [`MatcherInput`](./api-types#matcherinput) · [`ActionOptions`](./api-types#actionoptions) · [`ElementSummary`](./api-types#elementsummary)

Two taps in one gesture.

```ts theme={null}
await app.doubleTap('photo');
```

| Option | Default | Meaning |
| - | - | - |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the target and for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

### `multiTap(target, count, options?)`

```ts theme={null}
multiTap(
  target: MatcherInput,
  count: number,
  options?: ActionOptions,
): Promise<ElementSummary | undefined>
```

Types: [`MatcherInput`](./api-types#matcherinput) · [`ActionOptions`](./api-types#actionoptions) · [`ElementSummary`](./api-types#elementsummary)

`count` taps in one gesture.

```ts theme={null}
// triple-tap to open the hidden debug menu
await app.multiTap('version-label', 3);
```

| Option | Default | Meaning |
| - | - | - |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the target and for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

### `longPress(target, options?)`

```ts theme={null}
longPress(
  target: MatcherInput,
  options?: LongPressOptions,
): Promise<ElementSummary | undefined>
```

Types: [`MatcherInput`](./api-types#matcherinput) · [`LongPressOptions`](./api-types#longpressoptions) · [`ElementSummary`](./api-types#elementsummary)

Presses and holds the element.

```ts theme={null}
await app.longPress('message');

await app.longPress('message', { durationMs: 1500, point: { x: 10, y: 10 } });
```

| Option | Default | Meaning |
| - | - | - |
| `durationMs` | `800` | How long to hold |
| `point` | the center | `{ x, y }` in the element's own coordinates |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the target and for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

### `tapAt(point, options?)`

```ts theme={null}
tapAt(point: Point, options?: ActionOptions): Promise<void>
```

Types: [`Point`](./api-types#point) · [`ActionOptions`](./api-types#actionoptions)

Taps a point of the screen (window coordinates), whatever is there.

```ts theme={null}
// close a bottom sheet by tapping above it
await app.tapAt({ x: 200, y: 100 });
```

| Option | Default | Meaning |
| - | - | - |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

### `longPressAt(point, options?)`

```ts theme={null}
longPressAt(point: Point, options?: LongPressAtOptions): Promise<void>
```

Types: [`Point`](./api-types#point) · [`LongPressAtOptions`](./api-types#longpressatoptions)

Presses and holds a point of the screen (window coordinates).

```ts theme={null}
await app.longPressAt({ x: 200, y: 400 }, { durationMs: 1000 });
```

| Option | Default | Meaning |
| - | - | - |
| `durationMs` | `800` | How long to hold |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

## Text input

### `type(target, text, options?)`

```ts theme={null}
type(
  target: MatcherInput,
  text: string,
  options?: TypeOptions,
): Promise<ElementSummary | undefined>
```

Types: [`MatcherInput`](./api-types#matcherinput) · [`TypeOptions`](./api-types#typeoptions) · [`ElementSummary`](./api-types#elementsummary)

Focuses the input and enters `text` after what is already there. In `native` mode the text goes through
the system's input method, so any language works. On iOS and Android the whole text arrives at once; on the
web one key per character.

```ts theme={null}
await app.type('email', 'ann@example.com');

// one character at a time: for debounced search, input masks, onKeyPress
await app.type('search', 'milk', { perCharacter: true });
```

| Option | Default | Meaning |
| - | - | - |
| `perCharacter` | `false` | Type one character at a time, so the app sees every keystroke. The call waits for idle at the end |
| `intervalMs` | `80` | With `perCharacter`: the time between two characters |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the target and for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

### `replaceText(target, text, options?)`

```ts theme={null}
replaceText(
  target: MatcherInput,
  text: string,
  options?: ActionOptions,
): Promise<ElementSummary | undefined>
```

Types: [`MatcherInput`](./api-types#matcherinput) · [`ActionOptions`](./api-types#actionoptions) · [`ElementSummary`](./api-types#elementsummary)

Replaces the whole text of the input at once.

```ts theme={null}
await app.replaceText('email', 'bob@example.com');
```

| Option | Default | Meaning |
| - | - | - |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the target and for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

### `clear(target, options?)`

```ts theme={null}
clear(
  target: MatcherInput,
  options?: ActionOptions,
): Promise<ElementSummary | undefined>
```

Types: [`MatcherInput`](./api-types#matcherinput) · [`ActionOptions`](./api-types#actionoptions) · [`ElementSummary`](./api-types#elementsummary)

Empties the input.

```ts theme={null}
await app.clear('search');
```

| Option | Default | Meaning |
| - | - | - |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the target and for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

### `pressKey(target, key, options?)`

```ts theme={null}
pressKey(
  target: MatcherInput,
  key: KeyName,
  options?: ActionOptions,
): Promise<ElementSummary | undefined>
```

Types: [`MatcherInput`](./api-types#matcherinput) · [`KeyName`](./api-constants#list) · [`ActionOptions`](./api-types#actionoptions) · [`ElementSummary`](./api-types#elementsummary)

Sends the return key (`'enter'`) or `'backspace'` to the field. `'enter'` submits a single-line input and
adds a newline in a multi-line one. The field only has to exist: the key reaches it even where the
keyboard's return key would be out of reach.

```ts theme={null}
await app.type('search', 'milk');
await app.pressKey('search', KeyName.enter);

await app.pressKey('code-input', KeyName.backspace);
```

| Option | Default | Meaning |
| - | - | - |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the target and for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

### `dismissKeyboard(options?)`

```ts theme={null}
dismissKeyboard(options?: ActionOptions): Promise<void>
```

Types: [`ActionOptions`](./api-types#actionoptions)

Hides the software keyboard.

```ts theme={null}
await app.type('notes', 'Call before noon');
await app.dismissKeyboard();
```

| Option | Default | Meaning |
| - | - | - |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

## Scrolling

### `scroll(target, direction, options?)`

```ts theme={null}
scroll(
  target: MatcherInput,
  direction: Direction,
  options?: ScrollOptions,
): Promise<ElementSummary | undefined>
```

Types: [`MatcherInput`](./api-types#matcherinput) · [`Direction`](./api-constants#list) · [`ScrollOptions`](./api-types#scrolloptions) · [`ElementSummary`](./api-types#elementsummary)

Scrolls a scroll view. `'down'` reveals the content below. In `native` mode a finger drags and slows down
to a stop, so the content moves by about `distance` without a fling (less the system's touch slop: about
10 pt on iOS, 7% on Android).

```ts theme={null}
await app.scroll('feed', Direction.down);

await app.scroll('feed', Direction.down, { distance: 300, from: { x: 0.5, y: 0.8 } });
```

| Option | Default | Meaning |
| - | - | - |
| `distance` | — | How far to scroll, in logical units |
| `from` | — | Where the finger starts, normalized 0–1 within the element |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the target and for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

### `scrollTo(container, target, options?)`

```ts theme={null}
scrollTo(
  container: MatcherInput,
  target: MatcherInput,
  options?: ActionOptions,
): Promise<ElementSummary | undefined>
```

Types: [`MatcherInput`](./api-types#matcherinput) · [`ActionOptions`](./api-types#actionoptions) · [`ElementSummary`](./api-types#elementsummary)

Scrolls `container` until the center of `target` is visible (where a tap goes): down, then up; right,
then left in a horizontal list. Each step moves less than one screenful, so nothing is skipped. At an end
of the content, a target whose center stays cut off is returned as it is.

```ts theme={null}
await app.scrollTo('settings-list', 'sign-out');
await app.tap('sign-out');
```

| Option | Default | Meaning |
| - | - | - |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the target and for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

### `scrollToEdge(target, edge, options?)`

```ts theme={null}
scrollToEdge(
  target: MatcherInput,
  edge: Edge,
  options?: ActionOptions,
): Promise<ElementSummary | undefined>
```

Types: [`MatcherInput`](./api-types#matcherinput) · [`Edge`](./api-constants#list) · [`ActionOptions`](./api-types#actionoptions) · [`ElementSummary`](./api-types#elementsummary)

Scrolls to the `'top'`, `'bottom'`, `'left'` or `'right'` end. A virtualized list that renders more rows as
it scrolls is followed while it grows (in `native` mode with real flings).

```ts theme={null}
await app.scrollToEdge('feed', Edge.bottom);
await app.expectVisible({ text: 'No more posts' });
```

| Option | Default | Meaning |
| - | - | - |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the target and for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

### `scrollToIndex(list, index, options?)`

```ts theme={null}
scrollToIndex(
  list: MatcherInput,
  index: number,
  options?: ScrollToIndexOptions,
): Promise<ElementSummary | undefined>
```

Types: [`MatcherInput`](./api-types#matcherinput) · [`ScrollToIndexOptions`](./api-types#scrolltoindexoptions) · [`ElementSummary`](./api-types#elementsummary)

Brings row `index` of a `FlatList` / `FlashList` into view, also without `getItemLayout`.

```ts theme={null}
await app.scrollToIndex('contacts', 120);

// row 120 in the middle of the list
await app.scrollToIndex('contacts', 120, { viewPosition: 0.5 });
```

| Option | Default | Meaning |
| - | - | - |
| `viewPosition` | `0` | Where the row ends up: `0` top, `0.5` middle, `1` bottom |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the target and for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

`scrollTo`, `scrollToEdge` and `scrollToIndex` take several steps (at most 60); each step may wait up to the
call's timeout for the app to settle.

## Gestures

### `swipe(target, direction, options?)`

```ts theme={null}
swipe(
  target: MatcherInput,
  direction: Direction,
  options?: SwipeOptions,
): Promise<ElementSummary | undefined>
```

Types: [`MatcherInput`](./api-types#matcherinput) · [`Direction`](./api-constants#list) · [`SwipeOptions`](./api-types#swipeoptions) · [`ElementSummary`](./api-types#elementsummary)

A swipe with inertia. `direction` is the direction the finger moves.

```ts theme={null}
// reveal the row's delete button
await app.swipe({ id: 'todo-row', index: 0 }, Direction.left);

await app.swipe('carousel', Direction.left, { speed: Speed.fast, distance: 250 });
```

| Option | Default | Meaning |
| - | - | - |
| `speed` | `'normal'` | `'slow'`, `'normal'` or `'fast'` |
| `distance` | | How far the finger moves |
| `from` | | Where the finger starts, normalized 0–1 within the element |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the target and for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

### `drag(target, to, options?)`

```ts theme={null}
drag(
  target: MatcherInput,
  to: MatcherInput | { point: Point },
  options?: DragOptions,
): Promise<ElementSummary | undefined>
```

Types: [`MatcherInput`](./api-types#matcherinput) · [`Point`](./api-types#point) · [`DragOptions`](./api-types#dragoptions) · [`ElementSummary`](./api-types#elementsummary)

Presses and holds the element, moves it to the center of `to` (an element), or to `{ point }` (window
coordinates), and releases. It needs real touches: not available in `js` mode.

```ts theme={null}
// reorder: drag the first row onto the third
await app.drag({ id: 'todo-row', index: 0 }, { id: 'todo-row', index: 2 });

await app.drag('pin', { point: { x: 160, y: 420 } }, { holdMs: 300, speed: Speed.slow });
```

| Option | Default | Meaning |
| - | - | - |
| `holdMs` | `800` | How long to hold before moving |
| `speed` | `'normal'` | `'slow'`, `'normal'` or `'fast'` |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the target and for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

Pinch, rotate and other gestures with several fingers are on [multi-finger gestures](https://docs.quiesco.dev/api-gestures.md).

## Navigation

### `goBack(options?)`

```ts theme={null}
goBack(options?: ActionOptions): Promise<void>
```

Types: [`ActionOptions`](./api-types#actionoptions)

Goes back to the previous screen the way a user does on each platform: the Android back button (after
closing the keyboard), the browser's back, the navigation bar's back button on iOS, else the iOS edge
swipe. In an Expo Router app it fails when the route did not change.

```ts theme={null}
await app.tap({ text: 'Buy milk' });
await app.goBack();
await app.expectVisible('todo-list-screen');
```

| Option | Default | Meaning |
| - | - | - |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

### `pressBack(options?)`

```ts theme={null}
pressBack(options?: ActionOptions): Promise<void>
```

Types: [`ActionOptions`](./api-types#actionoptions)

The Android back button, or the browser's back on the web. Not available on iOS (`ACTION_NOT_SUPPORTED`):
use `goBack()` for a test that runs everywhere.

```ts theme={null}
// Android: close the bottom sheet with the back button
await app.pressBack();
```

| Option | Default | Meaning |
| - | - | - |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

### `openUrl(url, options?)`

```ts theme={null}
openUrl(url: string, options?: ActionOptions): Promise<void>
```

Types: [`ActionOptions`](./api-types#actionoptions)

Opens a deep link: in the app on iOS, with `am start` on Android, in the address bar on the web. While the
app is in the background (`app.device.sendToBackground()`), it opens the link from outside the app as
another app would; on iOS it answers the system's "Open in …?" question. Resolves when the app is in front
and idle.

```ts theme={null}
await app.openUrl('myapp://todos/42');
await app.expectText('detail-title', 'Buy milk');
```

| Option | Default | Meaning |
| - | - | - |
| `timeoutMs` | `sync.timeoutMs` (10 s) | How long to wait for the app to be idle |
| `sync` | `true` | `false`: do not wait for the app to be idle around this call ([call options](https://docs.quiesco.dev/api.md#call-options)) |
| `mode` | `actions.mode` | `'native'`: real touches and keyboard input; `'js'`: call the component's callbacks |

## Other inputs

Controls that hold a value — switches, sliders, pickers, date pickers — are set with `setValue` and
`adjustSlider`, and `accessibilityAction` performs a screen reader's action: see
[value controls](https://docs.quiesco.dev/api-value-controls.md).

## In `js` mode

When an action calls callbacks instead of touching the screen:

* a tap at a point presses the topmost element there;
* a tap on a switch without `onPress` toggles it through `onValueChange`;
* `pressKey` calls `onSubmitEditing` / `onKeyPress`;
* `scrollToEdge` sets the scroll offset;
* `from` is ignored;
* `drag` is not supported, since it needs real touches.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.