Skip to content

Commit ffb5fbf

Browse files
authored
Merge pull request #575 from lxKylin/interactivity-api.md
docs: interactivity-api
2 parents b59a28f + 6dacdac commit ffb5fbf

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

guide/browser/interactivity-api.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ function tripleClick(
117117
): Promise<void>
118118
```
119119

120-
Triggers a triple click event on an element. Since there is no `tripleclick` in browser api, this method will fire three click events in a row, and so you must check [click event detail](https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event#usage_notes) to filter the event: `evt.detail === 3`.
120+
在元素上触发三连击事件。由于浏览器 API 中没有 `tripleclick`,此方法会连续触发三次点击事件,因此你必须检查 [点击事件的 detail 属性](https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event#usage_notes) 来过滤事件:`evt.detail === 3`
121121

122-
Please refer to your provider's documentation for detailed explanation about how this method works.
122+
请参阅你的提供商文档以获取有关此方法工作原理的详细说明。
123123

124124
```ts
125125
import { page, userEvent } from '@vitest/browser/context'
@@ -141,11 +141,11 @@ test('triggers a triple click on an element', async () => {
141141
})
142142
```
143143

144-
References:
144+
相关链接:
145145

146-
- [Playwright `locator.click` API](https://playwright.dev/docs/api/class-locator#locator-click): implemented via `click` with `clickCount: 3` .
147-
- [WebdriverIO `browser.action` API](https://webdriver.io/docs/api/browser/action/): implemented via actions api with `move` plus three `down + up + pause` events in a row
148-
- [testing-library `tripleClick` API](https://testing-library.com/docs/user-event/convenience/#tripleClick)
146+
- [Playwright `locator.click` API](https://playwright.dev/docs/api/class-locator#locator-click):通过 `click` 方法并设置 `clickCount: 3` 来实现。
147+
- [WebdriverIO `browser.action` API](https://webdriver.io/docs/api/browser/action/):通过动作 API 实现,包含 `move` 操作加上连续的三个 `down + up + pause` 事件。
148+
- [testing-library `tripleClick` API](https://testing-library.com/docs/user-event/convenience/#tripleClick):通过 `tripleClick` 方法实现。
149149

150150
## userEvent.fill
151151

@@ -181,7 +181,7 @@ test('update input', async () => {
181181
在不需要输入特殊字符或对按键事件进行细粒度控制的情况下,我们建议使用此 API 而不是 [`userEvent.type`](#userevent-type)。
182182
:::
183183

184-
References:
184+
相关链接:
185185

186186
- [Playwright `locator.fill` API](https://playwright.dev/docs/api/class-locator#locator-fill)
187187
- [WebdriverIO `element.setValue` API](https://webdriver.io/docs/api/element/setValue)
@@ -195,7 +195,7 @@ function keyboard(text: string): Promise<void>
195195

196196
通过 `userEvent.keyboard` 可以触发键盘输入。如果任何输入有焦点,它就会在该输入中键入字符。否则,它将触发当前焦点元素(如果没有焦点元素,则为 `document.body`)上的键盘事件。
197197

198-
This API supports [user-event `keyboard` syntax](https://testing-library.com/docs/user-event/keyboard).
198+
API 支持 [user-event `keyboard` 语法](https://testing-library.com/docs/user-event/keyboard)
199199

200200
```ts
201201
import { userEvent } from '@vitest/browser/context'
@@ -209,7 +209,7 @@ test('trigger keystrokes', async () => {
209209
})
210210
```
211211

212-
References:
212+
相关链接:
213213

214214
- [Playwright `Keyboard` API](https://playwright.dev/docs/api/class-keyboard)
215215
- [WebdriverIO `action('key')` API](https://webdriver.io/docs/api/browser/action#key-input-source)
@@ -241,7 +241,7 @@ test('tab works', async () => {
241241
})
242242
```
243243

244-
References:
244+
相关链接:
245245

246246
- [Playwright `Keyboard` API](https://playwright.dev/docs/api/class-keyboard)
247247
- [WebdriverIO `action('key')` API](https://webdriver.io/docs/api/browser/action#key-input-source)
@@ -283,7 +283,7 @@ test('update input', async () => {
283283
Vitest 没有像 `input.type` 那样在定位器上公开 `.type` 方法,因为它的存在只是为了与 `userEvent` 库兼容。请考虑使用 `.fill`,因为它更快。
284284
:::
285285

286-
References:
286+
相关链接:
287287

288288
- [Playwright `locator.press` API](https://playwright.dev/docs/api/class-locator#locator-press)
289289
- [WebdriverIO `action('key')` API](https://webdriver.io/docs/api/browser/action#key-input-source)
@@ -314,7 +314,7 @@ test('clears input', async () => {
314314
})
315315
```
316316

317-
References:
317+
相关链接:
318318

319319
- [Playwright `locator.clear` API](https://playwright.dev/docs/api/class-locator#locator-clear)
320320
- [WebdriverIO `element.clearValue` API](https://webdriver.io/docs/api/element/clearValue)
@@ -371,7 +371,7 @@ test('clears input', async () => {
371371
`webdriverio` provider 不支持选择多个元素,因为它不提供选择多个元素的 API
372372
:::
373373

374-
References:
374+
相关链接:
375375

376376
- [Playwright `locator.selectOption` API](https://playwright.dev/docs/api/class-locator#locator-select-option)
377377
- [WebdriverIO `element.selectByIndex` API](https://webdriver.io/docs/api/element/selectByIndex)
@@ -406,7 +406,7 @@ test('hovers logo element', async () => {
406406
})
407407
```
408408

409-
References:
409+
相关链接:
410410

411411
- [Playwright `locator.hover` API](https://playwright.dev/docs/api/class-locator#locator-hover)
412412
- [WebdriverIO `element.moveTo` API](https://webdriver.io/docs/api/element/moveTo/)
@@ -439,7 +439,7 @@ test('unhover logo element', async () => {
439439
})
440440
```
441441

442-
References:
442+
相关链接:
443443

444444
- [Playwright `locator.hover` API](https://playwright.dev/docs/api/class-locator#locator-hover)
445445
- [WebdriverIO `element.moveTo` API](https://webdriver.io/docs/api/element/moveTo/)
@@ -477,7 +477,7 @@ test('can upload a file', async () => {
477477
`webdriverio` provider 仅在 `chrome``edge` 浏览器中支持该命令。目前也只支持字符串类型。
478478
:::
479479

480-
References:
480+
相关链接:
481481

482482
- [Playwright `locator.setInputFiles` API](https://playwright.dev/docs/api/class-locator#locator-set-input-files)
483483
- [WebdriverIO `browser.uploadFile` API](https://webdriver.io/docs/api/browser/uploadFile)
@@ -514,7 +514,7 @@ test('drag and drop works', async () => {
514514
`preview` provider不支持此 API
515515
:::
516516

517-
References:
517+
相关链接:
518518

519519
- [Playwright `frame.dragAndDrop` API](https://playwright.dev/docs/api/class-frame#frame-drag-and-drop)
520520
- [WebdriverIO `element.dragAndDrop` API](https://webdriver.io/docs/api/element/dragAndDrop/)
@@ -525,7 +525,7 @@ References:
525525
function copy(): Promise<void>
526526
```
527527

528-
Copy the selected text to the clipboard.
528+
将选中的文本复制到剪贴板。
529529

530530
```js
531531
import { page, userEvent } from '@vitest/browser/context'
@@ -548,7 +548,7 @@ test('copy and paste', async () => {
548548
})
549549
```
550550

551-
References:
551+
相关链接:
552552

553553
- [testing-library `copy` API](https://testing-library.com/docs/user-event/convenience/#copy)
554554

@@ -558,7 +558,7 @@ References:
558558
function cut(): Promise<void>
559559
```
560560

561-
Cut the selected text to the clipboard.
561+
将选中的文本剪切到剪贴板。
562562

563563
```js
564564
import { page, userEvent } from '@vitest/browser/context'
@@ -581,7 +581,7 @@ test('copy and paste', async () => {
581581
})
582582
```
583583

584-
References:
584+
相关链接:
585585

586586
- [testing-library `cut` API](https://testing-library.com/docs/user-event/clipboard#cut)
587587

@@ -591,8 +591,8 @@ References:
591591
function paste(): Promise<void>
592592
```
593593

594-
Paste the text from the clipboard. See [`userEvent.copy`](#userevent-copy) and [`userEvent.cut`](#userevent-cut) for usage examples.
594+
将文本从剪贴板粘贴。请参阅 [`userEvent.copy`](#userevent-copy) [`userEvent.cut`](#userevent-cut) 以获取使用示例。
595595

596-
References:
596+
相关链接:
597597

598598
- [testing-library `paste` API](https://testing-library.com/docs/user-event/clipboard#paste)

0 commit comments

Comments
 (0)