@@ -117,9 +117,9 @@ function tripleClick(
117
117
): Promise<void>
118
118
` ` `
119
119
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`。
121
121
122
- Please refer to your provider ' s documentation for detailed explanation about how this method works .
122
+ 请参阅你的提供商文档以获取有关此方法工作原理的详细说明。
123
123
124
124
` ` ` ts
125
125
import { page, userEvent } from '@vitest/browser/context'
@@ -141,11 +141,11 @@ test('triggers a triple click on an element', async () => {
141
141
})
142
142
` ` `
143
143
144
- References :
144
+ 相关链接:
145
145
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` 方法实现。
149
149
150
150
## userEvent .fill
151
151
@@ -181,7 +181,7 @@ test('update input', async () => {
181
181
在不需要输入特殊字符或对按键事件进行细粒度控制的情况下,我们建议使用此 API 而不是 [` userEvent.type ` ](#userevent - type )。
182
182
:::
183
183
184
- References :
184
+ 相关链接:
185
185
186
186
- [Playwright ` locator.fill ` API ](https :// playwright.dev/docs/api/class-locator#locator-fill)
187
187
- [WebdriverIO ` element.setValue ` API ](https :// webdriver.io/docs/api/element/setValue)
@@ -195,7 +195,7 @@ function keyboard(text: string): Promise<void>
195
195
196
196
通过 ` userEvent.keyboard ` 可以触发键盘输入。如果任何输入有焦点,它就会在该输入中键入字符。否则,它将触发当前焦点元素(如果没有焦点元素,则为 ` document.body ` )上的键盘事件。
197
197
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)。
199
199
200
200
` ` ` ts
201
201
import { userEvent } from '@vitest/browser/context'
@@ -209,7 +209,7 @@ test('trigger keystrokes', async () => {
209
209
})
210
210
` ` `
211
211
212
- References :
212
+ 相关链接:
213
213
214
214
- [Playwright ` Keyboard ` API ](https :// playwright.dev/docs/api/class-keyboard)
215
215
- [WebdriverIO ` action('key') ` API ](https :// webdriver.io/docs/api/browser/action#key-input-source)
@@ -241,7 +241,7 @@ test('tab works', async () => {
241
241
})
242
242
` ` `
243
243
244
- References :
244
+ 相关链接:
245
245
246
246
- [Playwright ` Keyboard ` API ](https :// playwright.dev/docs/api/class-keyboard)
247
247
- [WebdriverIO ` action('key') ` API ](https :// webdriver.io/docs/api/browser/action#key-input-source)
@@ -283,7 +283,7 @@ test('update input', async () => {
283
283
Vitest 没有像 ` input.type ` 那样在定位器上公开 ` .type ` 方法,因为它的存在只是为了与 ` userEvent ` 库兼容。请考虑使用 ` .fill ` ,因为它更快。
284
284
:::
285
285
286
- References :
286
+ 相关链接:
287
287
288
288
- [Playwright ` locator.press ` API ](https :// playwright.dev/docs/api/class-locator#locator-press)
289
289
- [WebdriverIO ` action('key') ` API ](https :// webdriver.io/docs/api/browser/action#key-input-source)
@@ -314,7 +314,7 @@ test('clears input', async () => {
314
314
})
315
315
` ` `
316
316
317
- References :
317
+ 相关链接:
318
318
319
319
- [Playwright ` locator.clear ` API ](https :// playwright.dev/docs/api/class-locator#locator-clear)
320
320
- [WebdriverIO ` element.clearValue ` API ](https :// webdriver.io/docs/api/element/clearValue)
@@ -371,7 +371,7 @@ test('clears input', async () => {
371
371
` webdriverio ` provider 不支持选择多个元素,因为它不提供选择多个元素的 API 。
372
372
:::
373
373
374
- References :
374
+ 相关链接:
375
375
376
376
- [Playwright ` locator.selectOption ` API ](https :// playwright.dev/docs/api/class-locator#locator-select-option)
377
377
- [WebdriverIO ` element.selectByIndex ` API ](https :// webdriver.io/docs/api/element/selectByIndex)
@@ -406,7 +406,7 @@ test('hovers logo element', async () => {
406
406
})
407
407
` ` `
408
408
409
- References :
409
+ 相关链接:
410
410
411
411
- [Playwright ` locator.hover ` API ](https :// playwright.dev/docs/api/class-locator#locator-hover)
412
412
- [WebdriverIO ` element.moveTo ` API ](https :// webdriver.io/docs/api/element/moveTo/)
@@ -439,7 +439,7 @@ test('unhover logo element', async () => {
439
439
})
440
440
` ` `
441
441
442
- References :
442
+ 相关链接:
443
443
444
444
- [Playwright ` locator.hover ` API ](https :// playwright.dev/docs/api/class-locator#locator-hover)
445
445
- [WebdriverIO ` element.moveTo ` API ](https :// webdriver.io/docs/api/element/moveTo/)
@@ -477,7 +477,7 @@ test('can upload a file', async () => {
477
477
` webdriverio ` provider 仅在 ` chrome ` 和 ` edge ` 浏览器中支持该命令。目前也只支持字符串类型。
478
478
:::
479
479
480
- References :
480
+ 相关链接:
481
481
482
482
- [Playwright ` locator.setInputFiles ` API ](https :// playwright.dev/docs/api/class-locator#locator-set-input-files)
483
483
- [WebdriverIO ` browser.uploadFile ` API ](https :// webdriver.io/docs/api/browser/uploadFile)
@@ -514,7 +514,7 @@ test('drag and drop works', async () => {
514
514
` preview ` provider 不支持此 API 。
515
515
:::
516
516
517
- References :
517
+ 相关链接:
518
518
519
519
- [Playwright ` frame.dragAndDrop ` API ](https :// playwright.dev/docs/api/class-frame#frame-drag-and-drop)
520
520
- [WebdriverIO ` element.dragAndDrop ` API ](https :// webdriver.io/docs/api/element/dragAndDrop/)
@@ -525,7 +525,7 @@ References:
525
525
function copy(): Promise<void>
526
526
` ` `
527
527
528
- Copy the selected text to the clipboard .
528
+ 将选中的文本复制到剪贴板。
529
529
530
530
` ` ` js
531
531
import { page, userEvent } from '@vitest/browser/context'
@@ -548,7 +548,7 @@ test('copy and paste', async () => {
548
548
})
549
549
` ` `
550
550
551
- References :
551
+ 相关链接:
552
552
553
553
- [testing - library ` copy ` API ](https :// testing-library.com/docs/user-event/convenience/#copy)
554
554
@@ -558,7 +558,7 @@ References:
558
558
function cut(): Promise<void>
559
559
` ` `
560
560
561
- Cut the selected text to the clipboard .
561
+ 将选中的文本剪切到剪贴板。
562
562
563
563
` ` ` js
564
564
import { page, userEvent } from '@vitest/browser/context'
@@ -581,7 +581,7 @@ test('copy and paste', async () => {
581
581
})
582
582
` ` `
583
583
584
- References :
584
+ 相关链接:
585
585
586
586
- [testing - library ` cut ` API ](https :// testing-library.com/docs/user-event/clipboard#cut)
587
587
@@ -591,8 +591,8 @@ References:
591
591
function paste(): Promise<void>
592
592
` ` `
593
593
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 ) 以获取使用示例。
595
595
596
- References :
596
+ 相关链接:
597
597
598
598
- [testing - library ` paste ` API ](https :// testing-library.com/docs/user-event/clipboard#paste)
0 commit comments