You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Types text into an element, if the element is visible. The element must be an `<input>` or `<textarea>` or have `[contenteditable]`.
450
450
451
451
If the element already has text in it, the additional text is appended to the existing text. **This is different from Puppeteer and Playwright's default .type behavior**.
452
452
453
+
The `delay` option controls the amount of time (ms) between keypresses (defaults to 1ms).
454
+
453
455
**Actionability checks**: It refuses to type into elements that are not [**attached**](#attached) or not [**visible**](#visible). You can override the visibility check by passing `{ force: true }`.
454
456
455
457
In the text, you can pass special commands using curly brackets to trigger special keypresses, similar to [user-event](https://github.com/testing-library/user-event#special-characters) and [Cypress](https://docs.cypress.io/api/commands/type.html#Arguments). Open an issue if you want more commands available here! Note: If you want to simulate individual keypresses independent from a text field, you can use Puppeteer's [page.keyboard API](https://pptr.dev/#?product=Puppeteer&version=v7.1.0&show=api-pagekeyboard)
Clears a text input's value, if the element is visible. The element must be an `<input>` or `<textarea>`.
489
+
490
+
**Actionability checks**: It refuses to clear elements that are not [**attached**](#attached) or not [**visible**](#visible). You can override the visibility check by passing `{ force: true }`.
491
+
492
+
```js
493
+
import { withBrowser } from'test-mule';
494
+
495
+
test(
496
+
'clear example',
497
+
withBrowser(async ({ utils, user, screen }) => {
498
+
awaitutils.injectHTML('<input value="text"/>');
499
+
constbutton=awaituser.clear(button);
500
+
}),
501
+
);
502
+
```
503
+
484
504
### Utilities API: `TestMuleUtils`
485
505
486
506
The utilities API provides shortcuts for loading and running code in the browser. The methods are wrappers around behavior that can be performed more verbosely with the [Puppeteer `Page` object](#testmulecontextpage). This API is exposed via the [`utils` property in `TestMuleContext`](#testmulecontextutils-testmuleutils)
0 commit comments