Skip to main content
This file has two login form tests. One types a username and checks the field. The other submits without a password and checks the browser’s validation message.

Watch it run

The test

type.test.mjs

How it works

  • type() types into the focused element, so each test clicks the username field first.
  • assert() can check a field’s contents (the username field contains "standard_user") as well as on-screen messages.
  • The second test calls focusApplication('Google Chrome') before asserting. This keeps Chrome in front when the validation tooltip appears.

Run it

The test is in the TestDriver SDK repository. Clone it, install dependencies, and run the file:
The test reads your API key from TD_API_KEY. Create a key at console.testdriver.ai/team/api-keys. Then set it in your environment or a .env file.