# pinch

Performs a pinch gesture on the given element on the screen.

info

Pinching is done based on native mobile gestures. It is only supported for the following drivers:

* [appium-uiautomator2-driver](https://github.com/appium/appium-uiautomator2-driver/blob/master/docs/android-mobile-gestures.md#mobile-pinchclosegesture) for Android
* [appium-xcuitest-driver](https://appium.github.io/appium-xcuitest-driver/latest/reference/execute-methods/#mobile-pinch) for iOS

This command only works with the following up-to-date components:

* Appium server (version 2.0.0 or higher)
* `appium-uiautomator2-driver` (for Android)
* `appium-xcuitest-driver` (for iOS)

Make sure your local or cloud-based Appium environment is regularly updated to avoid compatibility issues.

## Usage[​](#usage "Direct link to Usage")

```
await $(selector).pinch({ duration, scale })
```

## Parameters[​](#parameters "Direct link to Parameters")

| Name                               | Type           | Details                                                                                                                                                      |
| ---------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `options`<br />*optional*          | `PinchOptions` | pinch options (optional)                                                                                                                                     |
| `options.duration`<br />*optional* | `number`       | The duration in millisecond of how fast the pinch should be executed, minimal is 500 ms and max is 10000 ms. The default is 1500 ms (1.5 seconds) (optional) |
| `options.scale`<br />*optional*    | `number`       | The scale of how big the pinch should be according to the screen. Valid values must be float numbers in range 0..1, where 1.0 is 100% (optional)             |

## Example[​](#example "Direct link to Example")

pinch.js

```
it('should demonstrate a pinch on Google maps', async () => {
    const mapsElement = $('//*[@resource-id="com.google.android.apps.maps:id/map_frame"]')
    // Pinch with the default duration scale
    await mapsElement.pinch()
    // Pinch with a custom duration and scale
    await mapsElement.pinch({ duration: 4000, scale: 0.9 })
})
```

## Support[​](#support "Direct link to Support")

![Support for ios](data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTYuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+Cjwh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ny0xMDAuNjg4LTIzLjk2N2MtMzguMTg4LDAtNzYuMDg0LDI0Ljg2MS0xMDAuNzY2LDI0Ljg2MUM4OS4zMyw2MDguNzMsMCw0NTUuNjY2LDAsMzMyLjYyOAoJYzAtMTIxLjA1Miw3NS42MTItMTg0LjU1NCwxNDYuNTMzLTE4NC41NTRDMTkyLjYzOCwxNDguMDc0LDIyOC40MTYsMTc0LjY2MiwyNTIuMzg1LDE3NC42NjJ6Ii8+Cjwvc3ZnPgo=) ![Support for android](/assets/images/android-d941e94d5839760141de31c8446b67ce.svg)

**Supported platforms:** iOS, Android

note

Refer to the official [Appium driver documentation](https://appium.io/docs/en/latest/ecosystem/) to see which driver versions support this command.
