dblclick([options])
注意
此功能存在已知问题。详情请参阅 #471。
在选定的元素上进行鼠标双击。
参数 | 类型 | 默认值 | 描述 |
---|---|---|---|
options | 对象 | null | |
options.button | 字符串 | left | 执行操作时使用的鼠标按钮(left 、middle 或 right )。 |
options.delay | 数字 | 0 | 在 mousedown 和 mouseup 之间等待的毫秒数。 |
options.force | 布尔值 | false | 将此设为 true 将绕过可操作性检查(visible 、stable 、enabled )。 |
options.modifiers | 字符串数组 | null | 执行操作期间按下的修饰键(Alt 、Control 、Meta 或 Shift )。如果未指定,则使用当前按下的修饰键。 |
options.noWaitAfter | 布尔值 | false | 如果设为 true 且执行此操作导致导航发生,则不会等待其完成。 |
options.position | 对象 | null | 相对于元素左上角使用的点。如果未提供,则使用元素的可见点。 |
options.position.x | 数字 | 0 | x 坐标。 |
options.position.y | 数字 | 0 | y 坐标。 |
options.timeout | 数字 | 30000 | 最大时间(毫秒)。传入 0 可禁用超时。默认值被 BrowserContext 或 Page 上的 setDefaultTimeout 选项覆盖。 |
options.trial | 布尔值 | false | 将此设为 true 将执行可操作性检查,而不实际执行操作。 |
返回值
类型 | 描述 |
---|---|
Promise<void> | 在双击操作完成后兑现的 Promise。 |
示例
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();
await page.goto('https://test.k6.io/browser.php');
const button = page.locator('#counter-button');
await button.dblclick();
}