跳到正文
cccskills
免费在 GitHub 公开

testdriver:interacting-with-your-app

Click, hover, drag, and interact with located UI elements

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md4.4 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

<!-- Generated from interacting-with-your-app.mdx. DO NOT EDIT. -->

Overview

Once you've located an element, the Element object exposes methods to interact with it. Use these to click, hover, and perform mouse operations that drive your app.

Interaction Methods

click()

Click on the element.

await element.click(action)

Parameters:

  • action (string, optional) - Type of click: 'click' (default), 'double-click', 'right-click', 'hover', 'mouseDown', 'mouseUp'

Returns: Promise<void>

Example:

const button = await testdriver.find('submit button');
await button.click(); // Regular click

const file = await testdriver.find('document.txt');
await file.click('double-click'); // Double-click

const menu = await testdriver.find('settings icon');
await menu.click('right-click'); // Right-click
<Note> The element must be found before clicking. The `find()` method automatically locates the element. </Note>

hover()

Hover over the element without clicking.

await element.hover()

Returns: Promise<void>

Example:

const tooltip = await testdriver.find('info icon');
await tooltip.hover();
// Wait to see tooltip
await new Promise(resolve => setTimeout(resolve, 1000));

doubleClick()

Double-click on the element.

await element.doubleClick()

Returns: Promise<void>

Example:

const file = await testdriver.find('README.txt file icon');
await file.doubleClick();

rightClick()

Right-click on the element to open context menu.

await element.rightClick()

Returns: Promise<void>

Example:

const folder = await testdriver.find('Documents folder');
await folder.rightClick();

mouseDown() / mouseUp()

Press or release mouse button on the element (for drag operations).

await element.mouseDown()
await element.mouseUp()

Returns: Promise<void>

Example:

// Drag and drop
const item = await testdriver.find('draggable item');
await item.mouseDown();

// Move to drop target (using coordinates or another element)
const target = await testdriver.find('drop zone');
await target.hover();
await target.mouseUp();

Examples

Basic Element Interaction

// Find and click
const submitButton = await testdriver.find('submit button');
await submitButton.click();

// Find, verify, then interact
const emailInput = await testdriver.find('email input field');
if (emailInput.found()) {
  await emailInput.click();
  await testdriver.type('user@example.com');
}

Working with Forms

// Fill out a multi-field form
const nameField = await testdriver.find('name input field');
await nameField.click();
await testdriver.type('John Doe');

const emailField = await testdriver.find('email input field');
await emailField.click();
await testdriver.type('john@example.com');

const submitButton = await testdriver.find('submit button');
await submitButton.click();

Conditional Interactions

// Check if element exists before interacting
const closeButton = await testdriver.find('close popup button');

if (closeButton.found()) {
  await closeButton.click();
  console.log('Popup closed');
} else {
  console.log('No popup to close');
}

Re-locating Dynamic Elements

// Element that moves or changes
const notification = await testdriver.find('success notification');

// Do something that might cause it to move
await testdriver.scroll('down', 300);

// Re-locate the element
await notification.find();

if (notification.found()) {
  await notification.click();
}

Best Practices

<AccordionGroup> <Accordion title="Reuse element references when possible"> If you need to interact with the same element multiple times, reuse the reference:
```javascript
const input = await testdriver.find('search input');
await input.click();
await testdriver.type('first search');
await testdriver.pressKeys(['enter']);

// Re-use the same element reference
await input.click();
await testdriver.pressKeys(['ctrl', 'a']); // Select all
await testdriver.type('second search');
```
</Accordion> </AccordionGroup>

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

How the TestDriver agent behaves on GitHub issues, pull requests, and @mentions

中文简介正在准备中。当前显示原文说明。

testdriverai/testdriverai4752026年9月21日 更新

Execute natural language tasks using AI

中文简介正在准备中。当前显示原文说明。

testdriverai/testdriverai4752026年9月21日 更新

Make AI-powered assertions about screen state

中文简介正在准备中。当前显示原文说明。

testdriverai/testdriverai4752026年9月21日 更新

Deploy TestDriver on your AWS infrastructure using CloudFormation

中文简介正在准备中。当前显示原文说明。

testdriverai/testdriverai4752026年9月21日 更新

Speed up tests with screenshot-based caching

中文简介正在准备中。当前显示原文说明。

testdriverai/testdriverai4752026年9月21日 更新

How TestDriver learns your app and caches what it discovers for instant, deterministic replays

中文简介正在准备中。当前显示原文说明。

testdriverai/testdriverai4752026年9月21日 更新

查看 testdriverai 的全部技能

报告此技能的问题