Skip to main content
Type text into whatever has keyboard focus. Click the field first:
type() is a client method. Elements don’t have a type() method.

Signature

Parameters

string | number
required
The text to type. Numbers are converted to strings.
object
secret: true doesn’t hide what appears on screen. If the field shows its contents, the text is visible in the Dashcam recording.

Errors

Throws an error if text is undefined or null. This usually means an environment variable isn’t set.

Examples

Type a password

Read secrets from environment variables, not from your test code. See Secrets.

Replace the text in a field

type() adds to what’s already in the field. Select the old text first to replace it:

Type several lines

type() doesn’t press Enter for you. Use pressKeys() between lines:

Complete example

tests/login.test.mjs