跳到主要内容

捏合

在屏幕上的给定元素上执行捏合手势。

信息

捏合基于原生移动手势实现。它仅支持以下驱动程序:

此命令仅适用于以下最新组件:

  • Appium服务器(版本2.0.0或更高)
  • appium-uiautomator2-driver(用于Android)
  • appium-xcuitest-driver(用于iOS)

确保您的本地或基于云的Appium环境定期更新,以避免兼容性问题。

用法
$(selector).pinch({ duration, scale })
参数
名称类型详情
options
可选
PinchOptions捏合选项(可选)
options.duration
可选
number捏合手势执行的持续时间(毫秒),最小值为500毫秒,最大值为10000毫秒。默认值为1500毫秒(1.5秒)(可选)
options.scale
可选
number相对于屏幕的捏合比例大小。有效值必须是0..1范围内的浮点数,其中1.0代表100%(可选)
示例
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 })
})

Welcome! How can I help?

WebdriverIO AI Copilot