testdriverai 5.2.2 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/test-install.yml +1 -1
- package/README.md +5 -11
- package/agent.js +135 -99
- package/docs/30x30.mdx +84 -0
- package/docs/action/browser.mdx +129 -0
- package/docs/action/os.mdx +157 -0
- package/docs/action/output.mdx +98 -0
- package/docs/action/performance.mdx +71 -0
- package/docs/action/prerun.mdx +80 -0
- package/docs/action/secrets.mdx +103 -0
- package/docs/action/setup.mdx +115 -0
- package/docs/bugs/jira.mdx +208 -0
- package/docs/cli/overview.mdx +65 -0
- package/docs/commands/assert.mdx +31 -0
- package/docs/commands/exec.mdx +42 -0
- package/docs/commands/focus-application.mdx +29 -0
- package/docs/commands/hover-image.mdx +32 -0
- package/docs/commands/hover-text.mdx +37 -0
- package/docs/commands/if.mdx +43 -0
- package/docs/commands/match-image.mdx +41 -0
- package/docs/commands/press-keys.mdx +30 -0
- package/docs/commands/run.mdx +30 -0
- package/docs/commands/scroll-until-image.mdx +33 -0
- package/docs/commands/scroll-until-text.mdx +37 -0
- package/docs/commands/scroll.mdx +33 -0
- package/docs/commands/type.mdx +29 -0
- package/docs/commands/wait-for-image.mdx +31 -0
- package/docs/commands/wait-for-text.mdx +35 -0
- package/docs/commands/wait.mdx +30 -0
- package/docs/docs.json +226 -0
- package/docs/exporting/playwright.mdx +159 -0
- package/docs/features/auto-healing.mdx +124 -0
- package/docs/features/cross-platform.mdx +106 -0
- package/docs/features/generation.mdx +180 -0
- package/docs/features/github.mdx +161 -0
- package/docs/features/parallel-testing.mdx +130 -0
- package/docs/features/reusable-snippets.mdx +124 -0
- package/docs/features/selectorless.mdx +62 -0
- package/docs/features/visual-assertions.mdx +123 -0
- package/docs/getting-started/ci.mdx +196 -0
- package/docs/getting-started/generating.mdx +210 -0
- package/docs/getting-started/running.mdx +67 -0
- package/docs/getting-started/setup.mdx +133 -0
- package/docs/getting-started/writing.mdx +99 -0
- package/docs/guide/assertions.mdx +195 -0
- package/docs/guide/authentication.mdx +150 -0
- package/docs/guide/code.mdx +169 -0
- package/docs/guide/locating.mdx +136 -0
- package/docs/guide/setup-teardown.mdx +161 -0
- package/docs/guide/variables.mdx +218 -0
- package/docs/guide/waiting.mdx +199 -0
- package/docs/importing/csv.mdx +196 -0
- package/docs/importing/gherkin.mdx +142 -0
- package/docs/importing/jira.mdx +172 -0
- package/docs/importing/testrail.mdx +161 -0
- package/docs/integrations/electron.mdx +152 -0
- package/docs/integrations/netlify.mdx +98 -0
- package/docs/integrations/vercel.mdx +177 -0
- package/docs/interactive/assert.mdx +51 -0
- package/docs/interactive/generate.mdx +41 -0
- package/docs/interactive/run.mdx +36 -0
- package/docs/interactive/save.mdx +53 -0
- package/docs/interactive/undo.mdx +47 -0
- package/docs/issues.mdx +9 -0
- package/docs/overview/comparison.mdx +82 -0
- package/docs/overview/faq.mdx +122 -0
- package/docs/overview/quickstart.mdx +66 -0
- package/docs/overview/what-is-testdriver.mdx +73 -0
- package/docs/quickstart.mdx +66 -0
- package/docs/reference/commands/scroll.mdx +0 -0
- package/docs/reference/interactive/assert.mdx +0 -0
- package/docs/security/action.mdx +62 -0
- package/docs/security/agent.mdx +62 -0
- package/docs/security/dashboard.mdx +0 -0
- package/docs/security/platform.mdx +54 -0
- package/docs/tutorials/advanced-test.mdx +79 -0
- package/docs/tutorials/basic-test.mdx +41 -0
- package/electron/icon.png +0 -0
- package/electron/overlay.html +7 -3
- package/electron/overlay.js +75 -15
- package/electron/tray-buffered.png +0 -0
- package/electron/tray.png +0 -0
- package/index.js +75 -34
- package/lib/commander.js +22 -1
- package/lib/commands.js +87 -19
- package/lib/config.js +10 -1
- package/lib/focus-application.js +30 -23
- package/lib/generator.js +58 -7
- package/lib/init.js +48 -19
- package/lib/ipc.js +50 -0
- package/lib/logger.js +19 -6
- package/lib/overlay.js +82 -36
- package/lib/parser.js +9 -7
- package/lib/resources/prerun.yaml +17 -0
- package/lib/sandbox.js +2 -3
- package/lib/sdk.js +0 -2
- package/lib/session.js +3 -1
- package/lib/speak.js +0 -2
- package/lib/subimage/opencv.js +0 -4
- package/lib/system.js +56 -39
- package/lib/upload-secrets.js +65 -0
- package/lib/validation.js +175 -0
- package/package.json +2 -1
- package/postinstall.js +0 -24
- package/lib/websockets.js +0 -85
- package/test.md +0 -8
- package/test.yml +0 -18
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Generating Test Plans with TestDriver.ai"
|
|
3
|
+
sidebarTitle: "Generating Tests"
|
|
4
|
+
description: "Learn how to generate test plans locally with TestDriver.ai and integrate them into your testing workflow."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Running Locally Generated Test Plans with TestDriver.ai and Managing Generated PRs
|
|
8
|
+
|
|
9
|
+
This guide explains how to use **TestDriver.ai** to generate test plans locally, commit them to your repository, and run them in parallel using GitHub Actions. Additionally, it covers how **TestDriver.ai** can automatically create **pull requests (PRs)** for test results, enabling collaboration and review.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Workflow Overview
|
|
14
|
+
|
|
15
|
+
1. **Generate Test Plans Locally**: Use the `/generate` command to create test plans.
|
|
16
|
+
2. **Commit Test Plans to the Repository**: Add the generated files to your repository for version control.
|
|
17
|
+
3. **Run Tests in Parallel**: Use GitHub Actions to execute the committed test plans in parallel.
|
|
18
|
+
4. **Create PRs for Test Results**: Automatically generate PRs for test results, allowing teams to review and merge updates.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Step 1: Generate Test Plans Locally
|
|
23
|
+
|
|
24
|
+
### Run `/generate` Locally
|
|
25
|
+
|
|
26
|
+
1. Open your terminal and navigate to your project directory.
|
|
27
|
+
2. Run the following command to start TestDriver.ai locally:
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
testdriverai
|
|
32
|
+
> /generate web 10
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This will generate 10 test plans for your website or application.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### Save the Generated Files
|
|
41
|
+
|
|
42
|
+
TestDriver.ai will save the generated test plans as YAML files in the `testdriver/generate/` directory by default. For example:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
testdriver/
|
|
46
|
+
├── generate/
|
|
47
|
+
│ ├── test_1.yml
|
|
48
|
+
│ ├── test_2.yml
|
|
49
|
+
│ ├── test_3.yml
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### Commit the Files to Your Repository
|
|
56
|
+
|
|
57
|
+
1. Add the generated files to your Git repository:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
git add testdriver/generate/
|
|
61
|
+
git commit -m "Add locally generated test plans"
|
|
62
|
+
git push origin main
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Step 2: Run Tests in Parallel Using GitHub Actions
|
|
68
|
+
|
|
69
|
+
### Workflow: **Run Locally Generated Tests**
|
|
70
|
+
|
|
71
|
+
This workflow dynamically discovers the committed test files and runs them in parallel.
|
|
72
|
+
|
|
73
|
+
#### Example Workflow: `.github/workflows/run-tests.yml`
|
|
74
|
+
|
|
75
|
+
```yaml
|
|
76
|
+
name: Run Locally Generated Test Plans
|
|
77
|
+
|
|
78
|
+
on:
|
|
79
|
+
push:
|
|
80
|
+
paths:
|
|
81
|
+
- 'testdriver/generate/**'
|
|
82
|
+
workflow_dispatch:
|
|
83
|
+
|
|
84
|
+
jobs:
|
|
85
|
+
gather-test-files:
|
|
86
|
+
name: Gather Test Files
|
|
87
|
+
runs-on: ubuntu-latest
|
|
88
|
+
outputs:
|
|
89
|
+
test_files: ${{ steps.test_list.outputs.files }}
|
|
90
|
+
steps:
|
|
91
|
+
- name: Check out repository
|
|
92
|
+
uses: actions/checkout@v2
|
|
93
|
+
|
|
94
|
+
- name: Find all test files
|
|
95
|
+
id: test_list
|
|
96
|
+
run: |
|
|
97
|
+
FILES=$(ls ./testdriver/generate/*.yml)
|
|
98
|
+
FILES_JSON=$(echo "$FILES" | jq -R -s -c 'split("\n")[:-1]')
|
|
99
|
+
echo "::set-output name=files::$FILES_JSON"
|
|
100
|
+
|
|
101
|
+
run-tests:
|
|
102
|
+
name: Run Tests in Parallel
|
|
103
|
+
needs: gather-test-files
|
|
104
|
+
runs-on: ubuntu-latest
|
|
105
|
+
strategy:
|
|
106
|
+
matrix:
|
|
107
|
+
test_file: ${{ fromJson(needs.gather-test-files.outputs.test_files) }}
|
|
108
|
+
fail-fast: false
|
|
109
|
+
steps:
|
|
110
|
+
- name: Check out repository
|
|
111
|
+
uses: actions/checkout@v2
|
|
112
|
+
|
|
113
|
+
- name: Run TestDriver.ai
|
|
114
|
+
uses: testdriverai/action@main
|
|
115
|
+
with:
|
|
116
|
+
key: ${{ secrets.TESTDRIVER_API_KEY }}
|
|
117
|
+
prompt: |
|
|
118
|
+
1. /run ${{ matrix.test_file }}
|
|
119
|
+
create-pr: true
|
|
120
|
+
pr-title: "TestDriver.ai / Test Results for ${{ matrix.test_file }}"
|
|
121
|
+
pr-branch: testdriver/results-${{ matrix.test_file }}
|
|
122
|
+
env:
|
|
123
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
124
|
+
FORCE_COLOR: "3"
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### Workflow Steps Explained
|
|
132
|
+
|
|
133
|
+
1. **Trigger on Push**:
|
|
134
|
+
- The workflow triggers whenever files in the `testdriver/generate/` directory are pushed to the repository.
|
|
135
|
+
|
|
136
|
+
2. **Gather Test Files**:
|
|
137
|
+
- The `gather-test-files` job collects all YAML files in the `testdriver/generate/` directory and outputs them as a JSON array.
|
|
138
|
+
|
|
139
|
+
3. **Run Tests in Parallel**:
|
|
140
|
+
- The `run-tests` job uses the matrix strategy to run each test file in parallel.
|
|
141
|
+
|
|
142
|
+
4. **Create PRs for Test Results**:
|
|
143
|
+
- For each test file, a new branch is created with the test results, and a PR is opened for review.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Step 3: Generated PRs for Test Results
|
|
148
|
+
|
|
149
|
+
### How PRs Are Created
|
|
150
|
+
|
|
151
|
+
When the tests are executed, TestDriver.ai automatically:
|
|
152
|
+
1. Creates a new branch for each test result (e.g., `testdriver/results-test_1.yml`).
|
|
153
|
+
2. Commits the test results to the branch.
|
|
154
|
+
3. Opens a pull request with the test results for review.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
### Example PR Details
|
|
159
|
+
|
|
160
|
+
#### PR Title:
|
|
161
|
+
`TestDriver.ai / Test Results for test_1.yml`
|
|
162
|
+
|
|
163
|
+
#### PR Description:
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
### Test Results for test_1.yml
|
|
168
|
+
|
|
169
|
+
**Test Summary**:
|
|
170
|
+
- ✅ Step 1: Opened the homepage.
|
|
171
|
+
- ✅ Step 2: Verified the login button is visible.
|
|
172
|
+
- ❌ Step 3: Failed to submit the login form.
|
|
173
|
+
|
|
174
|
+
**Details**:
|
|
175
|
+
- Error: The "Submit" button was not clickable.
|
|
176
|
+
|
|
177
|
+
Please review the test results and address any issues.
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
### Benefits of Generated PRs
|
|
184
|
+
|
|
185
|
+
1. **Collaboration**: Teams can review test results directly in GitHub and discuss issues in the PR comments.
|
|
186
|
+
2. **Traceability**: Each test result is tied to a specific branch and PR, making it easy to track changes.
|
|
187
|
+
3. **Continuous Improvement**: Failed tests can be addressed and merged back into the main branch after fixes.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Example Output
|
|
192
|
+
|
|
193
|
+
### GitHub Actions Dashboard:
|
|
194
|
+
- ✅ **Run Tests in Parallel**: All tests passed.
|
|
195
|
+
- ❌ **Run Tests in Parallel**: 1 test failed. View logs for details.
|
|
196
|
+
|
|
197
|
+
### Pull Requests:
|
|
198
|
+
- **PR #123**: `TestDriver.ai / Test Results for test_1.yml`
|
|
199
|
+
- **PR #124**: `TestDriver.ai / Test Results for test_2.yml`
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Summary
|
|
204
|
+
|
|
205
|
+
1. **Generate Tests Locally**: Use the `/generate` command to create test plans.
|
|
206
|
+
2. **Commit and Run Tests**: Push the generated files to your repository and execute them in parallel.
|
|
207
|
+
3. **Review Generated PRs**: Collaborate on test results using automatically created pull requests.
|
|
208
|
+
4. **Merge Fixes**: Address issues and merge the PRs back into the main branch.
|
|
209
|
+
|
|
210
|
+
By leveraging TestDriver.ai's ability to generate and manage PRs, you can streamline your testing workflow and improve collaboration across your team.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Running Tests Locally with TestDriver.ai"
|
|
3
|
+
sidebarTitle: "Running Tests"
|
|
4
|
+
description: "Learn how to execute test plans locally using TestDriver.ai's `/run` command for debugging and validation."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Running Tests Locally with `/run` in TestDriver.ai
|
|
8
|
+
|
|
9
|
+
The `/run` command in TestDriver.ai allows you to execute previously created test plans locally. This is particularly useful for debugging, validating test scripts, or running tests in a controlled environment before committing them to a CI/CD pipeline.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## How to Use `/run`
|
|
14
|
+
|
|
15
|
+
1. **Navigate to Your Test Directory**:
|
|
16
|
+
Ensure you are in the directory where your test files are stored (e.g., `testdriver/`).
|
|
17
|
+
|
|
18
|
+
2. **Run a Specific Test File**:
|
|
19
|
+
Use the `/run` command followed by the path to the test file you want to execute. For example:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
testdriverai
|
|
23
|
+
> /run testdriver/test.yml
|
|
24
|
+
```
|
|
25
|
+
This will execute the test plan defined in `test.yml`.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Benefits of Running Tests Locally
|
|
30
|
+
|
|
31
|
+
1. **Quick Feedback**:
|
|
32
|
+
- Test changes immediately without waiting for CI/CD pipelines.
|
|
33
|
+
- Validate test scripts before committing them to version control.
|
|
34
|
+
|
|
35
|
+
2. **Debugging**:
|
|
36
|
+
- Identify and fix issues in test scripts or application behavior in a controlled environment.
|
|
37
|
+
|
|
38
|
+
3. **Offline Testing**:
|
|
39
|
+
- Run tests locally without requiring access to cloud-based runners or external environments.
|
|
40
|
+
|
|
41
|
+
4. **Iterative Development**:
|
|
42
|
+
- Modify test scripts and re-run them quickly to refine test cases.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Example Workflow for Local Testing
|
|
47
|
+
|
|
48
|
+
1. **Create a Test File**:
|
|
49
|
+
Save the following YAML file as `testdriver/test.yml`:
|
|
50
|
+
|
|
51
|
+
```yaml
|
|
52
|
+
version: 4.2.18
|
|
53
|
+
steps:
|
|
54
|
+
- prompt: Open the homepage
|
|
55
|
+
- prompt: Verify the login button is visible
|
|
56
|
+
- prompt: Click the login button
|
|
57
|
+
- prompt: Verify the login form is displayed
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
2. **Run the Test Locally**:
|
|
61
|
+
Execute the test using the `/run` command:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
testdriverai
|
|
65
|
+
> /run testdriver/test.yml
|
|
66
|
+
```
|
|
67
|
+
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Setting Up TestDriver.ai"
|
|
3
|
+
sidebarTitle: "Setup Guide"
|
|
4
|
+
description: "Comprehensive guide to installing and setting up TestDriver.ai for your testing needs."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### **TestDriver.ai Installation Guide**
|
|
9
|
+
|
|
10
|
+
Follow these steps to install and set up TestDriver.ai:
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
<Steps>
|
|
16
|
+
|
|
17
|
+
<Step title="Install NodeJS">
|
|
18
|
+
|
|
19
|
+
Ensure you have Node.js (v16 or higher) installed.
|
|
20
|
+
|
|
21
|
+
Check your Node.js version:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
node -v
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
If not installed, download it from [Node.js Official Website](https://nodejs.org/).
|
|
28
|
+
|
|
29
|
+
</Step>
|
|
30
|
+
<Step title="Install NPM">
|
|
31
|
+
**npm**: Comes with Node.js. Verify `npm` is installed:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm -v
|
|
35
|
+
```
|
|
36
|
+
</Step>
|
|
37
|
+
<Step title="Install TestDriver">
|
|
38
|
+
|
|
39
|
+
Install the TestDriver CLI globally using npm:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install -g testdriverai
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Verify the installation:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
testdriverai --version
|
|
49
|
+
```
|
|
50
|
+
</Step>
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
<Step title="Set Up Your Test Runner">
|
|
54
|
+
|
|
55
|
+
TestDriver.ai requires a runner to execute tests. You can use either a hosted sandbox or your own computer.
|
|
56
|
+
|
|
57
|
+
- **TestDriver Sandbox** - Run tests in a ephemeral linux virtual machine. Recommended for ease of use, added privacy, and parallelization. Requires a TestDriver API key.
|
|
58
|
+
- **Local Runner** - Run tests on your own computer. Recommended for working with existing user sessions, files, and applications. Requires additional setup.
|
|
59
|
+
|
|
60
|
+
<Tabs>
|
|
61
|
+
<Tab title="Hosted Sandbox Setup">
|
|
62
|
+
|
|
63
|
+
Run `testdriverai init` in your project directory and choose "yes" for the sandbox option. This will prompt you for your API key.
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
Beginning setup...
|
|
67
|
+
✔ Use TestDriver Sandbox Runners? (Recommended) … yes
|
|
68
|
+
? API KEY (from https://app.testdriver.ai/team) › ********
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
This will write the `TD_VM` and `TD_API_KEY` values to `.env` file in your project directory.
|
|
72
|
+
|
|
73
|
+
</Tab>
|
|
74
|
+
<Tab title="Local Windows Setup">
|
|
75
|
+
|
|
76
|
+
#### Install Python & Visual Studio Build Tools
|
|
77
|
+
|
|
78
|
+
```powershell
|
|
79
|
+
choco install python visualstudio2022-workload-vctools -y
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Install NodeJS
|
|
83
|
+
|
|
84
|
+
You will also need NodeJS if you don't have it yet.
|
|
85
|
+
|
|
86
|
+
```powershell
|
|
87
|
+
choco install nodejs-lts --version="20.17.0"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### Set Execution Policy
|
|
91
|
+
|
|
92
|
+
Open a new terminal with admin privileges and execute the following command :
|
|
93
|
+
```powershell
|
|
94
|
+
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
95
|
+
```
|
|
96
|
+
This gives TestDriver the right to execute it's scripts and is only valid for the current user.
|
|
97
|
+
</Tab>
|
|
98
|
+
<Tab title="Local Mac Setup">
|
|
99
|
+
#### Enable Screen Recording Permissions
|
|
100
|
+
|
|
101
|
+
TestDriver requires screen recording permissions to capture your screen during test execution.
|
|
102
|
+
|
|
103
|
+
- Open **System Preferences > Security & Privacy > Privacy > Screen Recording**.
|
|
104
|
+
- Check the box next to your terminal application (e.g., Terminal, iTerm2) to allow screen recording.
|
|
105
|
+
|
|
106
|
+
This is required for TestDriver to capture your screen during test execution.
|
|
107
|
+
|
|
108
|
+
#### Enable Accessibility Permissions
|
|
109
|
+
|
|
110
|
+
- Open **System Preferences > Security & Privacy > Privacy > Accessibility**.
|
|
111
|
+
- Check the box next to your terminal application (e.g., Terminal, iTerm2) to allow accessibility features.
|
|
112
|
+
|
|
113
|
+
This is required for TestDriver to interact with your applications during test execution.
|
|
114
|
+
|
|
115
|
+
</Tab>
|
|
116
|
+
</Tabs>
|
|
117
|
+
</Step>
|
|
118
|
+
|
|
119
|
+
<Step title="Run TestDriver in Interactive Mode">
|
|
120
|
+
Start TestDriver in interactive mode.
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
testdriverai
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
You should see a prompt like this:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
Howdy! I'm TestDriver v4.2.26
|
|
130
|
+
```
|
|
131
|
+
</Step>
|
|
132
|
+
|
|
133
|
+
</Steps>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Writing Tests with TestDriver.ai"
|
|
3
|
+
sidebarTitle: "Writing Tests"
|
|
4
|
+
description: "Step-by-step guide to writing and refining tests using TestDriver.ai's interactive CLI."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
The TestDriver.ai interactive CLI allows you to create, refine, and execute tests dynamically using natural language commands. Here's how to get started.
|
|
8
|
+
|
|
9
|
+
### Prepare Your Environment
|
|
10
|
+
|
|
11
|
+
Before we get started, let's set up your machine to collaborate with TestDriver.
|
|
12
|
+
|
|
13
|
+
#### Displays
|
|
14
|
+
|
|
15
|
+
TestDriver isn't like any framework you've used before. TestDriver makes decisions based on what it can see on your display!
|
|
16
|
+
|
|
17
|
+
<Tip>TestDriver only knows about what it can see on your primary display!</Tip>
|
|
18
|
+
|
|
19
|
+
When you enter commands into TestDriver, the current window will minimize and the `focus-window` command will bring Chrome or other applications to the foreground.
|
|
20
|
+
|
|
21
|
+
For now, set up your environment with a browser window and your terminal side by side like so:
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
#### Application State
|
|
26
|
+
|
|
27
|
+
The application you want to test should be visible before you run the testdriverai command.
|
|
28
|
+
|
|
29
|
+
For our example, make a new incognito window in Chrome and load our test webpage:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
https://testdriverai.github.io/example-react-todo/
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
<Tip>Make sure to reset your application state before running every test!</Tip>
|
|
36
|
+
|
|
37
|
+
### Launch Interactive Mode
|
|
38
|
+
|
|
39
|
+
Run the following command to launch the TestDriver interactive mode:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
testdriverai
|
|
43
|
+
```
|
|
44
|
+
You’ll see a prompt (`>`) where you can enter commands.
|
|
45
|
+
|
|
46
|
+
### Write Tests Using Natural Language
|
|
47
|
+
|
|
48
|
+
Simply describe what you want to test in plain English. For example:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
> click sign up
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
TestDriver will analyze your screen, interpret your instruction, and generate a test script to achieve the goal. It can see your UI, control the mouse and keyboard, and automate complex workflows—all through simple commands.
|
|
55
|
+
|
|
56
|
+
```yaml
|
|
57
|
+
thinking...
|
|
58
|
+
|
|
59
|
+
To accomplish the goal of clicking "Sign Up," we need to
|
|
60
|
+
focus on the Google Chrome application and then click on
|
|
61
|
+
the "Sign Up" button.
|
|
62
|
+
|
|
63
|
+
Here are the steps:
|
|
64
|
+
|
|
65
|
+
1. Focus the Google Chrome application.
|
|
66
|
+
2. Click on the "Sign Up" button.
|
|
67
|
+
|
|
68
|
+
commands:
|
|
69
|
+
- command: focus-application
|
|
70
|
+
name: Google Chrome
|
|
71
|
+
- command: hover-text
|
|
72
|
+
text: Sign Up
|
|
73
|
+
description: button in the header
|
|
74
|
+
action: click
|
|
75
|
+
|
|
76
|
+
command='focus-application' name='Google Chrome'
|
|
77
|
+
command='hover-text' text='Sign Up' description='button in the header' action='click'
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 4. Refine Your Test
|
|
81
|
+
|
|
82
|
+
If something doesn’t work as intended:
|
|
83
|
+
|
|
84
|
+
- Use `/undo` to remove the last step:
|
|
85
|
+
```
|
|
86
|
+
> /undo
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Modify your prompt or add new steps to refine the test.
|
|
90
|
+
|
|
91
|
+
### 5. Save Your Test
|
|
92
|
+
|
|
93
|
+
Once you’re satisfied with the test, save it to a YAML file:
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
> /save
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
This generates a reusable YAML file (e.g., `testdriver.yaml`) with all the steps.
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Using Assertions in TestDriver.ai"
|
|
3
|
+
sidebarTitle: "Assertions"
|
|
4
|
+
description: "Comprehensive guide to understanding and implementing assertions in TestDriver.ai for robust test validation."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Guide: Using Assertions in TestDriver.ai
|
|
8
|
+
|
|
9
|
+
Assertions in TestDriver.ai allow you to validate that your application behaves as expected during a test. By using the `assert` command and visual assertions, you can ensure that specific conditions are met, such as verifying the presence of text, images, or UI elements on the screen.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## What Are Assertions?
|
|
14
|
+
|
|
15
|
+
Assertions are checks that validate whether a specific condition is true. If the condition is not met, the test will fail, providing feedback on what went wrong.
|
|
16
|
+
|
|
17
|
+
### Types of Assertions in TestDriver.ai:
|
|
18
|
+
1. **Text Assertions**: Verify that specific text is visible on the screen.
|
|
19
|
+
2. **Visual Assertions**: Validate the presence of images, icons, or UI elements.
|
|
20
|
+
3. **Custom Assertions**: Use descriptive conditions to check for specific outcomes.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## How to Use the `assert` Command
|
|
25
|
+
|
|
26
|
+
The `assert` command is used to validate conditions during a test. It checks whether the specified expectation is true.
|
|
27
|
+
|
|
28
|
+
### Syntax:
|
|
29
|
+
|
|
30
|
+
```yaml
|
|
31
|
+
- command: assert
|
|
32
|
+
expect: <condition to check>
|
|
33
|
+
async: <true|false> # Optional, defaults to false
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
- **`expect`**: The condition to validate (e.g., "The login form is displayed").
|
|
39
|
+
- **`async`**: (Optional) If set to `true`, the test will continue running without waiting for the assertion to pass.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
### Example: Text Assertion
|
|
44
|
+
|
|
45
|
+
#### YAML Command:
|
|
46
|
+
|
|
47
|
+
```yaml
|
|
48
|
+
- command: assert
|
|
49
|
+
expect: The login form is displayed
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
This assertion checks if the login form is visible on the screen.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### Example: Async Assertion
|
|
59
|
+
|
|
60
|
+
#### YAML Command:
|
|
61
|
+
|
|
62
|
+
```yaml
|
|
63
|
+
- command: assert
|
|
64
|
+
expect: The success message is displayed
|
|
65
|
+
async: true
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
This assertion runs asynchronously, allowing the test to continue without waiting for the success message to appear.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Visual Assertions
|
|
75
|
+
|
|
76
|
+
Visual assertions validate the presence of images, icons, or UI elements on the screen. These are particularly useful for verifying non-text elements.
|
|
77
|
+
|
|
78
|
+
### Example: Verifying an Image
|
|
79
|
+
|
|
80
|
+
#### YAML Command:
|
|
81
|
+
|
|
82
|
+
```yaml
|
|
83
|
+
- command: hover-image
|
|
84
|
+
description: Company logo in the top-left corner
|
|
85
|
+
action: hover
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
This command hovers over the company logo to ensure it is present on the screen.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
### Example: Verifying a Button
|
|
95
|
+
|
|
96
|
+
#### YAML Command:
|
|
97
|
+
|
|
98
|
+
```yaml
|
|
99
|
+
- command: hover-text
|
|
100
|
+
text: Submit
|
|
101
|
+
description: Blue button with the text 'Submit' at the bottom of the form
|
|
102
|
+
action: hover
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
This command hovers over the "Submit" button to confirm its presence.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Combining Assertions with Other Commands
|
|
112
|
+
|
|
113
|
+
Assertions can be combined with navigation and interaction commands to validate workflows.
|
|
114
|
+
|
|
115
|
+
### Example: Login Workflow with Assertions
|
|
116
|
+
|
|
117
|
+
#### YAML Command:
|
|
118
|
+
|
|
119
|
+
```yaml
|
|
120
|
+
version: 4.2.18
|
|
121
|
+
steps:
|
|
122
|
+
- prompt: Open the homepage
|
|
123
|
+
commands:
|
|
124
|
+
- command: hover-text
|
|
125
|
+
text: Login
|
|
126
|
+
description: Login button in the top-right corner
|
|
127
|
+
action: click
|
|
128
|
+
|
|
129
|
+
- prompt: Verify the login form is displayed
|
|
130
|
+
commands:
|
|
131
|
+
- command: assert
|
|
132
|
+
expect: The login form is displayed
|
|
133
|
+
|
|
134
|
+
- prompt: Enter credentials and submit
|
|
135
|
+
commands:
|
|
136
|
+
- command: hover-text
|
|
137
|
+
text: Email
|
|
138
|
+
description: Email input field
|
|
139
|
+
action: click
|
|
140
|
+
- command: type
|
|
141
|
+
text: user@example.com
|
|
142
|
+
- command: hover-text
|
|
143
|
+
text: Password
|
|
144
|
+
description: Password input field
|
|
145
|
+
action: click
|
|
146
|
+
- command: type
|
|
147
|
+
text: password123
|
|
148
|
+
- command: hover-text
|
|
149
|
+
text: Submit
|
|
150
|
+
description: Submit button
|
|
151
|
+
action: click
|
|
152
|
+
|
|
153
|
+
- prompt: Verify the dashboard is displayed
|
|
154
|
+
commands:
|
|
155
|
+
- command: assert
|
|
156
|
+
expect: The dashboard is displayed
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Debugging Assertions
|
|
164
|
+
|
|
165
|
+
1. **Review Error Messages**:
|
|
166
|
+
- If an assertion fails, TestDriver.ai provides detailed error messages to help identify the issue.
|
|
167
|
+
|
|
168
|
+
2. **Use Visual Feedback**:
|
|
169
|
+
- Leverage screenshots and visual feedback to verify the state of the application during the assertion.
|
|
170
|
+
|
|
171
|
+
3. **Refine Descriptions**:
|
|
172
|
+
- Ensure that the `expect` condition or `description` is specific and matches the application's state.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Best Practices for Assertions
|
|
177
|
+
|
|
178
|
+
1. **Be Specific**:
|
|
179
|
+
- Use clear and concise conditions for assertions (e.g., "The login form is displayed").
|
|
180
|
+
|
|
181
|
+
2. **Use Visual Assertions for Non-Text Elements**:
|
|
182
|
+
- Validate images, icons, and other UI elements using `hover-image` or `hover-text`.
|
|
183
|
+
|
|
184
|
+
3. **Combine Assertions with Navigation**:
|
|
185
|
+
- Place assertions after navigation or interaction steps to validate the application's state.
|
|
186
|
+
|
|
187
|
+
4. **Leverage Async Assertions**:
|
|
188
|
+
- Use `async: true` for non-blocking checks, especially for dynamic content.
|
|
189
|
+
|
|
190
|
+
5. **Test Incrementally**:
|
|
191
|
+
- Add assertions step-by-step to validate each part of the workflow.
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
By using the `assert` command and visual assertions effectively, you can create robust and reliable tests that ensure your application behaves as expected.
|