---
title: "Setup"
sidebarTitle: "Setup"
description: "Get started with TestDriver in minutes."
icon: "download"
mode: "wide"
---

<Steps>
  <Step title="Set up your environment">
      
    Copy your API key from [the TestDriver dashboard](https://app.testdriver.ai/team), and set it as an environment variable.
    
    <Tabs>
      <Tab title="macOS / Linux">
        ```bash Export an environment variable on macOS or Linux systems
        export TD_API_KEY="your_api_key_here"
        ```
      </Tab>
      <Tab title="Windows">
      ```powershell Export an environment variable in PowerShell
      setx TD_API_KEY "your_api_key_here"
      ```
      </Tab>
    </Tabs>

  </Step>
  <Step title="Try an example test">
      
    Download the TestDriver GitHub repository and run the web example test.

    ```bash
    git clone https://github.com/testdriverai/cli testdriverai
    cd testdriverai/testdriver/examples/web
    ```

    TestDriver tests are written in YAML, a human-readable data format. The `example.yaml` file contains a series of steps that the agent will execute.

    ```yaml testdriver/test.yaml
    steps:
      - prompt: log in
      - prompt: add an item to the cart
      - prompt: click on the cart icon
      - prompt: complete checkout
    ```

    Each step has a `prompt` that describes what the agent should do. The agent will use the prompt to generate [commands](/commands/assert) that make the tests faster and more reliable the next time you run the test.

  </Step>
  <Step title="Generate test steps from prompts">
    
    Run the following command to run the test file. TestDriver will spawn a virtual machine, launch the sandbox test page, and execute the steps defined in the `example.yaml` file.

    ```bash
    npx testdriverai@latest run example.yaml --write --heal
    ```

    The `--write` flag tells TestDriver to save any generated commands to the test file, and the `--heal` flag allows TestDriver to recover from unexpected issues during the test run.

  </Step>
  <Step title="Run a regression test">

    ```yaml
      version: 6.0.0
      steps:
        - prompt: focus chrome
          commands:
            - command: focus-application
              name: Google Chrome
        - prompt: enter a username
          commands:
            - command: hover-text
              text: Username
              description: username input field
              action: click
            - command: type
              text: standard_user
        - prompt: enter a password
          commands:
            - command: hover-text
              text: Password
              description: password input field
              action: click
            - command: type
              text: secret_password
      ```

      The `--write` command tells the agent to save the generated commands to the test file, and the `--heal` command gives the agent permission to recover if something goes wrong.

  </Step>
</Steps>
