Watch it run
The test
add-to-cart.test.mjs
How it works
- Each
find()description starts with the visible label, then adds context (“Add to Cart, add to cart button under TestDriver Hat”). - The context tells the AI which of several identical buttons to pick.
performLogin()is the reusable helper from Click an icon. It reads the on-screen password withextract()and types it withsecret: true.assert()checks the result in plain language, not by inspecting markup.
Run it
The test is in the TestDriver SDK repository. Clone it, install dependencies, and run the file:TD_API_KEY. Create a key at console.testdriver.ai/team/api-keys. Then set it in your environment or a .env file.

