---
title: "GestureScope"
description: "The receiver scope for injecting gestures on the SemanticsNode identified by the corresponding
[SemanticsNodeInteraction]. Gestures can be injected by calling methods defined on
[GestureScope], such as [click] or [swipe]. The [SemanticsNodeInteraction] can be found by one of
the finder methods such as
[onNode][androidx.compose.ui.test.SemanticsNodeInteractionsProvider.onNode].

The functions in [GestureScope] can roughly be divided into two groups: full gestures and
individual touch events. The individual touch events are: [down], [move] and friends, [up],
[cancel] and [advanceEventTime]. Full gestures are all the other functions, like [click],
[doubleClick], [swipe], etc. See the documentation of [down] for more information about
individual events. If you execute a full gesture while in the middle of another gesture, an
[IllegalStateException] or [IllegalArgumentException] can be thrown when the pointerId is
unintentionally used for both gestures. If you want to perform e.g. a click during a partially
performed gesture, make sure they use different pointer ids.

Note that all events generated by the gesture methods are batched together and sent as a whole
after [performGesture] has executed its code block.

Next to the functions, [GestureScope] also exposes several properties that allow you to get
[coordinates][Offset] within a node, like the [top left corner][topLeft], its [center], or some
percentage of the size ([percentOffset]).

Example of performing a click:


Example of performing a swipe up:


Example of performing an L-shaped gesture:"
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>


> **Deprecated** Replaced by TouchInjectionScope

```kotlin
class GestureScope(node: SemanticsNode, testContext: TestContext)
```


The receiver scope for injecting gestures on the SemanticsNode identified by the corresponding
`SemanticsNodeInteraction`. Gestures can be injected by calling methods defined on
`GestureScope`, such as `click` or `swipe`. The `SemanticsNodeInteraction` can be found by one of
the finder methods such as
`onNode`.

The functions in `GestureScope` can roughly be divided into two groups: full gestures and
individual touch events. The individual touch events are: `down`, `move` and friends, `up`,
`cancel` and `advanceEventTime`. Full gestures are all the other functions, like `click`,
`doubleClick`, `swipe`, etc. See the documentation of `down` for more information about
individual events. If you execute a full gesture while in the middle of another gesture, an
`IllegalStateException` or `IllegalArgumentException` can be thrown when the pointerId is
unintentionally used for both gestures. If you want to perform e.g. a click during a partially
performed gesture, make sure they use different pointer ids.

Note that all events generated by the gesture methods are batched together and sent as a whole
after `performGesture` has executed its code block.

Next to the functions, `GestureScope` also exposes several properties that allow you to get
`coordinates` within a node, like the `top left corner`, its `center`, or some
percentage of the size (`percentOffset`).

Example of performing a click:


Example of performing a swipe up:


Example of performing an L-shaped gesture:


## Properties

<div class='sourceset sourceset-common'>Common</div>


```kotlin
val visibleSize: IntSize
```


Returns the size of the visible part of the node we're interacting with. This is contrary to
`SemanticsNode.size`, which returns the unclipped size of the node.




## Code Examples

### gestureClick
```kotlin
@Suppress("DEPRECATION")
fun gestureClick() {
    composeTestRule.onNodeWithTag("myComponent").performGesture { click() }
}
```

### gestureLShape
```kotlin
@Suppress("DEPRECATION")
fun gestureLShape() {
    composeTestRule.onNodeWithTag("myComponent").performGesture {
        down(topLeft)
        moveTo(topLeft + percentOffset(0f, .1f))
        moveTo(topLeft + percentOffset(0f, .2f))
        moveTo(topLeft + percentOffset(0f, .3f))
        moveTo(topLeft + percentOffset(0f, .4f))
        moveTo(centerLeft)
        moveTo(centerLeft + percentOffset(.1f, 0f))
        moveTo(centerLeft + percentOffset(.2f, 0f))
        moveTo(centerLeft + percentOffset(.3f, 0f))
        moveTo(centerLeft + percentOffset(.4f, 0f))
        moveTo(center)
        up()
    }
}
```

### gestureSwipeUp
```kotlin
@Suppress("DEPRECATION")
fun gestureSwipeUp() {
    composeTestRule.onNodeWithTag("myComponent").performGesture { swipeUp() }
}
```

