菜单
开源

tap()

在指定坐标处模拟点击(触发 touchstarttouchend 事件)。xy 参数是相对于主框架左上角的点击坐标。

参数类型默认值描述
xnumber0x 坐标。
ynumber0y 坐标。

示例

JavaScript
import { browser } from 'k6/browser';

export const options = {
  scenarios: {
    browser: {
      executor: 'shared-iterations',
      options: {
        browser: {
          type: 'chromium',
        },
      },
    },
  },
};

export default async function () {
  const page = await browser.newPage({
    hasTouch: true,
  });

  const touchscreen = page.touchscreen;
  await touchscreen.tap(50, 50);
}