跳到主要内容

缩放

在屏幕上对给定元素执行缩放手势。

信息

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

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

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

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

用法
$(selector).zoom({ duration, scale })
参数
名称类型详情
options
可选
PinchAndZoomOptions缩放选项(可选)
options.duration
可选
number缩放执行的持续时间(毫秒),最小值为500毫秒,最大值为10000毫秒。默认值为1500毫秒(1.5秒)(可选)
options.scale
可选
number相对于屏幕的缩放比例。有效值必须是0..1范围内的浮点数,其中1.0表示100%(可选)
示例
zoom.js
it('should demonstrate a zoom on Google maps', async () => {
const mapsElement = $('//*[@resource-id="com.google.android.apps.maps:id/map_frame"]')
// Zoom with the default duration scale
await mapsElement.zoom()
// Zoom with a custom duration and scale
await mapsElement.zoom({ duration: 4000, scale: 0.9 })
})

Welcome! How can I help?

WebdriverIO AI Copilot