testdriverai 6.0.23 → 6.0.24-canary.fffd04a.0

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.
Files changed (107) hide show
  1. package/.github/workflows/acceptance-tests.yml +5 -1
  2. package/docs/action/ami.mdx +4 -3
  3. package/docs/action/performance.mdx +26 -8
  4. package/docs/action/secrets.mdx +11 -31
  5. package/docs/apps/chrome-extensions.mdx +1 -1
  6. package/docs/apps/desktop-apps.mdx +11 -8
  7. package/docs/apps/static-websites.mdx +7 -7
  8. package/docs/bugs/jira.mdx +12 -75
  9. package/docs/cli/overview.mdx +6 -6
  10. package/docs/commands/exec.mdx +32 -37
  11. package/docs/commands/focus-application.mdx +13 -2
  12. package/docs/commands/hover-image.mdx +29 -5
  13. package/docs/commands/hover-text.mdx +10 -16
  14. package/docs/commands/if.mdx +24 -21
  15. package/docs/commands/match-image.mdx +17 -9
  16. package/docs/commands/press-keys.mdx +55 -3
  17. package/docs/commands/remember.mdx +13 -9
  18. package/docs/commands/run.mdx +10 -4
  19. package/docs/commands/scroll-until-image.mdx +25 -11
  20. package/docs/commands/scroll-until-text.mdx +17 -10
  21. package/docs/commands/scroll.mdx +22 -8
  22. package/docs/commands/type.mdx +6 -6
  23. package/docs/commands/wait-for-image.mdx +20 -7
  24. package/docs/commands/wait-for-text.mdx +14 -12
  25. package/docs/commands/wait.mdx +8 -1
  26. package/docs/docs.json +4 -6
  27. package/docs/exporting/junit.mdx +3 -3
  28. package/docs/exporting/playwright.mdx +2 -2
  29. package/docs/features/auto-healing.mdx +3 -3
  30. package/docs/features/generation.mdx +2 -4
  31. package/docs/features/parallel-testing.mdx +3 -13
  32. package/docs/features/reusable-snippets.mdx +3 -3
  33. package/docs/features/selectorless.mdx +8 -2
  34. package/docs/features/visual-assertions.mdx +2 -2
  35. package/docs/getting-started/ci.mdx +42 -51
  36. package/docs/getting-started/cli.mdx +3 -9
  37. package/docs/getting-started/editing.mdx +13 -10
  38. package/docs/getting-started/running.mdx +7 -2
  39. package/docs/getting-started/vscode.mdx +4 -7
  40. package/docs/guide/assertions.mdx +2 -4
  41. package/docs/guide/authentication.mdx +8 -10
  42. package/docs/guide/code.mdx +14 -12
  43. package/docs/guide/environment-variables.mdx +13 -12
  44. package/docs/guide/lifecycle.mdx +39 -31
  45. package/docs/guide/variables.mdx +30 -20
  46. package/docs/guide/waiting.mdx +2 -2
  47. package/docs/importing/csv.mdx +3 -4
  48. package/docs/importing/jira.mdx +6 -12
  49. package/docs/importing/testrail.mdx +6 -6
  50. package/docs/integrations/electron.mdx +30 -56
  51. package/docs/integrations/netlify.mdx +9 -12
  52. package/docs/integrations/vercel.mdx +6 -42
  53. package/docs/interactive/explore.mdx +8 -10
  54. package/docs/interactive/run.mdx +9 -4
  55. package/docs/interactive/save.mdx +2 -2
  56. package/docs/overview/comparison.mdx +68 -60
  57. package/docs/overview/performance.mdx +0 -1
  58. package/docs/overview/what-is-testdriver.mdx +1 -1
  59. package/docs/scenarios/log-in.mdx +2 -2
  60. package/docs/security/platform.mdx +4 -2
  61. package/docs/snippets/test-prereqs.mdx +1 -1
  62. package/docs/snippets/tests/assert-replay.mdx +7 -5
  63. package/docs/snippets/tests/assert-yaml.mdx +2 -3
  64. package/docs/snippets/tests/exec-js-replay.mdx +7 -5
  65. package/docs/snippets/tests/exec-js-yaml.mdx +3 -4
  66. package/docs/snippets/tests/exec-shell-replay.mdx +7 -5
  67. package/docs/snippets/tests/exec-shell-yaml.mdx +4 -5
  68. package/docs/snippets/tests/hover-image-replay.mdx +7 -5
  69. package/docs/snippets/tests/hover-image-yaml.mdx +4 -6
  70. package/docs/snippets/tests/hover-text-replay.mdx +7 -5
  71. package/docs/snippets/tests/hover-text-with-description-replay.mdx +7 -5
  72. package/docs/snippets/tests/hover-text-with-description-yaml.mdx +4 -10
  73. package/docs/snippets/tests/hover-text-yaml.mdx +2 -3
  74. package/docs/snippets/tests/match-image-replay.mdx +7 -5
  75. package/docs/snippets/tests/match-image-yaml.mdx +6 -6
  76. package/docs/snippets/tests/press-keys-replay.mdx +7 -5
  77. package/docs/snippets/tests/press-keys-yaml.mdx +5 -6
  78. package/docs/snippets/tests/remember-replay.mdx +7 -5
  79. package/docs/snippets/tests/remember-yaml.mdx +25 -6
  80. package/docs/snippets/tests/scroll-replay.mdx +7 -5
  81. package/docs/snippets/tests/scroll-until-image-replay.mdx +7 -0
  82. package/docs/snippets/tests/scroll-until-image-yaml.mdx +14 -0
  83. package/docs/snippets/tests/scroll-until-text-replay.mdx +7 -5
  84. package/docs/snippets/tests/scroll-until-text-yaml.mdx +4 -8
  85. package/docs/snippets/tests/scroll-yaml.mdx +4 -13
  86. package/docs/snippets/tests/type-repeated-replay.mdx +7 -5
  87. package/docs/snippets/tests/type-repeated-yaml.mdx +2 -3
  88. package/docs/snippets/tests/type-replay.mdx +7 -5
  89. package/docs/snippets/tests/type-yaml.mdx +2 -5
  90. package/docs/snippets/tests/wait-for-image-replay.mdx +7 -0
  91. package/docs/snippets/tests/wait-for-image-yaml.mdx +18 -0
  92. package/docs/snippets/tests/wait-for-text-replay.mdx +7 -0
  93. package/docs/snippets/tests/wait-for-text-yaml.mdx +18 -0
  94. package/docs/snippets/tests/wait-replay.mdx +7 -0
  95. package/docs/snippets/tests/wait-yaml.mdx +13 -0
  96. package/docs/styles.css +46 -0
  97. package/package.json +3 -9
  98. package/testdriver/edge-cases/prompt-nested.yaml +2 -1
  99. package/docs/action/setup.mdx +0 -120
  100. package/docs/interactive/assert.mdx +0 -65
  101. package/docs/interactive/dry.mdx +0 -58
  102. package/docs/interactive/generate.mdx +0 -55
  103. package/docs/interactive/undo.mdx +0 -58
  104. package/docs/snippets/comments.mdx +0 -1
  105. package/docs/snippets/tests/prompt-replay.mdx +0 -5
  106. package/docs/snippets/tests/prompt-yaml.mdx +0 -10
  107. package/docs/snippets/yml-warning.mdx +0 -4
@@ -14,7 +14,11 @@ jobs:
14
14
  gather-test-files:
15
15
  name: Gather Test Files
16
16
  runs-on: ubuntu-latest
17
- if: github.event.pull_request.base.ref == 'main' || github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
17
+ if: >
18
+ (github.event_name == 'workflow_dispatch') ||
19
+ (github.ref == 'refs/heads/main') ||
20
+ (github.event_name == 'pull_request_review' &&
21
+ (github.event.review.state == 'approved' || github.event.review.state == 'changes_requested'))
18
22
  outputs:
19
23
  test_files: ${{ steps.test_list.outputs.files }}
20
24
  steps:
@@ -6,9 +6,10 @@ icon: "image"
6
6
  ---
7
7
 
8
8
  <Tip>
9
- This guide is specifically for **Enterprise Plan customers** who have access
10
- to the shared TestDriver AMI. If you are on a different plan, please contact
11
- your account manager for more information.
9
+ This guide is specifically for [Enterprise Plan
10
+ customers](/account/enterprise) who have access to the shared TestDriver AMI.
11
+ If you are on a different plan, please contact your account manager for more
12
+ information.
12
13
  </Tip>
13
14
 
14
15
  <Steps>
@@ -28,15 +28,28 @@ Parallel testing allows you to split your test actions into multiple files and r
28
28
  manageable pieces. To run multiple separate tests, use a test matrix strategy.
29
29
  </Warning>
30
30
 
31
- Example:
31
+ #### Example
32
32
 
33
- ```yaml
34
- strategy:
35
- matrix:
36
- test_file:
37
- - tests/login.yaml
38
- - tests/search.yaml
39
- - tests/cart.yaml
33
+ ```yaml .github/workflows/testdriver.yaml focus={3-9, 14}
34
+ run tests:
35
+ name: Run tests in parallel
36
+ strategy:
37
+ matrix:
38
+ test_file:
39
+ - tests/login.yaml
40
+ - tests/search.yaml
41
+ - tests/cart.yaml
42
+ steps:
43
+ - name: Checkout repository
44
+ uses: actions/checkout@v4
45
+
46
+ - name: Run the tests
47
+ run: npx testdriverai@latest run testdriver/${{ matrix.test_file }}
48
+ env:
49
+ FORCE_COLOR: 3
50
+ TD_API_KEY: ${{ secrets.TD_API_KEY }}
51
+ TD_WEBSITE: https://testdriver-sandbox.vercel.app
52
+ TD_THIS_FILE: ${{ matrix.test }}
40
53
  ```
41
54
 
42
55
  ---
@@ -55,6 +68,11 @@ action: click
55
68
  method: turbo
56
69
  ```
57
70
 
71
+ <Note>
72
+ `turbo` is the default method that is currently implemented. The other method
73
+ being `ai`
74
+ </Note>
75
+
58
76
  ---
59
77
 
60
78
  ### 3. Use `async` asserts
@@ -25,8 +25,8 @@ To securely use secrets in your TestDriver test files, replace hardcoded values
25
25
 
26
26
  ### Example test file
27
27
 
28
- ```yaml
29
- version: 4.1.35
28
+ ```yaml login.yaml highlight={11, 12, 21, 22}
29
+ version: 6.0.0
30
30
  steps:
31
31
  - prompt: sign in with username and password
32
32
  commands:
@@ -48,6 +48,10 @@ steps:
48
48
  action: click
49
49
  - command: type
50
50
  text: ${TD_PASSWORD}
51
+ - command: hover-text
52
+ text: Log In
53
+ description: log in button
54
+ action: click
51
55
  ```
52
56
 
53
57
  ---
@@ -69,42 +73,18 @@ For detailed instructions, refer to the [GitHub Docs on using secrets](https://d
69
73
 
70
74
  When running TestDriver tests via the CLI in GitHub Actions, supply your secrets in the `env` section of the workflow step.
71
75
 
72
- ### Example workflow
73
-
74
- ```yaml .github/workflows/testdriver.yaml
75
- name: TestDriver Test
76
-
77
- permissions:
78
- actions: read
79
- contents: read
80
- statuses: write
81
- pull-requests: write
82
-
83
- jobs:
84
- test:
85
- name: "TestDriver"
86
- steps:
87
- - name: Check out repository
88
- uses: actions/checkout@v4
89
-
90
- - name: Run TestDriver
91
- run: npx testdriverai@latest run tests/signin.yaml --headless
92
- env:
93
- TD_API_KEY: ${{ secrets.TD_API_KEY }}
94
- TD_USERNAME: ${{ secrets.TD_USERNAME }}
95
- TD_PASSWORD: ${{ secrets.TD_PASSWORD }}
96
- ```
97
-
98
- ---
76
+ <Card title="Adding secrets to CI" icon="link" href="/guide/authentication">
77
+ Check out our authentication page to see how to add secrets in your CI
78
+ workflow.
79
+ </Card>
99
80
 
100
81
  ## Best practices
101
82
 
102
83
  - **Use Descriptive Names**: Name your secrets clearly (for example, `TD_USERNAME`, `TD_PASSWORD`) to make them easy to identify.
103
84
  - **Rotate Secrets Regularly**: Update your secrets periodically to enhance security.
104
85
  - **Limit Access**: Only provide access to secrets for workflows and team members that require them.
105
- - **Mask Secrets**: Ensure all secrets are masked in logs by using the `TD_` prefix.
106
86
 
107
- ---
87
+ ## <Note>To ensure all secrets are masked in logs, use the `TD_` prefix.</Note>
108
88
 
109
89
  ## Notes
110
90
 
@@ -29,7 +29,7 @@ TestDriver provides a powerful solution for testing Chrome extensions. With our
29
29
 
30
30
  ## Getting started
31
31
 
32
- You can test a preinstalled extension or test by installing an extension. If the extension is in development mode, turn this on by checking the "Developer mode" checkbox in the Chrome extensions page. From there you can load the unpacked extension by selecting the folder where your extension is located. To download the files onto the VM if you are performing a test on cloud hosted runners, see the [Lifecycle](/guide/lifecycle-prerun) and [Prerun](/action/pre-post-scripts) docs.
32
+ You can test a preinstalled extension or test by installing an extension. If the extension is in development mode, turn this on by checking the "Developer mode" checkbox in the Chrome extensions page. From there you can load the unpacked extension by selecting the folder where your extension is located. To download the files onto the VM if you are performing a test on cloud hosted runners, see the [Lifecycle](/guide/lifecycle) docs.
33
33
 
34
34
  ## Sample test steps
35
35
 
@@ -46,28 +46,29 @@ TestDriver supports a wide range of desktop applications, including:
46
46
 
47
47
  ## Installation
48
48
 
49
- To use TestDriver with desktop applications, no special setup is needed. Simply run the local agent to interact with applications on your local machine, or add instructions to `prerun.yaml` to tell the runner to launch or install the application. Here is an example that performs a calculation on a calculator app:
49
+ To use TestDriver with desktop applications, no special setup is needed. Simply run the local agent to interact with applications on your local machine, or add instructions to `provision.yaml` to tell the runner to launch or install the application. Here is an example that performs a calculation on a calculator app:
50
50
 
51
- ```yaml
52
- version: 5.5.5
51
+ ```yaml testdriver/lifecycle/provision.yaml
52
+ version: 6.0.0
53
53
  steps:
54
54
  - prompt: launch a calculator
55
55
  commands:
56
56
  - command: exec
57
57
  lang: pwsh
58
- code: start /B calc.exe
58
+ code: |
59
+ start /B calc.exe
59
60
  timeout /t 5
60
61
  - command: wait-for-text
61
62
  text: "calculator"
62
63
  timeout: 30000
63
64
  ```
64
65
 
65
- A `calculator_test.yaml` file might look like this:
66
+ A `calculator.yaml` file might look like this:
66
67
 
67
- ```yaml
68
- version: 5.5.5
68
+ ```yaml calculator.yaml
69
+ version: 6.0.0
69
70
  steps:
70
- - prompt: /try performing the operation 2 + 2 = on the calculator that is opened
71
+ - prompt: perform the operation 2 + 2 = on the calculator that is opened
71
72
  commands:
72
73
  - command: focus-application
73
74
  name: galculator
@@ -83,6 +84,8 @@ steps:
83
84
  - command: hover-image
84
85
  description: equals button on the calculator
85
86
  action: click
87
+ - command: assert
88
+ expected: 4 is displayed as the result
86
89
  ```
87
90
 
88
91
  ## Conclusion
@@ -28,27 +28,27 @@ To get started with testing static websites using TestDriver, follow these steps
28
28
  1. [**Follow our quick start guide to set up your TestDriver account.**](/getting-started/setup)
29
29
  2. **Create a new test project** in your TestDriver dashboard.
30
30
  3. **Add your static website URL** to the test settings.
31
- It looks like this in the `prerun.yaml` file:
31
+ It looks like this in the `provision.yaml` file:
32
32
 
33
- ```yaml
34
- version: 5.1.1
33
+ ```yaml testdriver/lifecycle/provision.yaml
34
+ version: 6.0.0
35
35
  steps:
36
36
  - prompt: launch chrome
37
37
  commands:
38
38
  - command: exec
39
39
  lang: pwsh
40
- code:
40
+ code: |
41
41
  Start-Process "C:/Program Files/Google/Chrome/Application/chrome.exe" -ArgumentList "--start-maximized", "${TD_WEBSITE}"
42
42
  exit
43
43
  - command: wait-for-text
44
- text: "Google Chrome"
44
+ text: ${TD_WEBSITE}
45
45
  timeout: 30000
46
46
  ```
47
47
 
48
- Set the `TD_WEBSITE` environment variable to the URL of your static website. This will allow TestDriver to launch the browser and navigate to your website. You can do this by adding this `prerun.yaml` file to your project or by simply using:
48
+ Set the `TD_WEBSITE` environment variable to the URL of your static website. This will allow TestDriver to launch the browser and navigate to your website. You can do this by adding this `provision.yaml` file to your project or by simply using:
49
49
 
50
50
  ```bash
51
51
  npx testdriverai@latest init
52
52
  ```
53
53
 
54
- Running init will create the `prerun.yaml` file for you and ask you which website to load with your test.
54
+ Running init will create the `provision.yaml` file for you and ask you which website to load with your test.
@@ -42,9 +42,9 @@ This guide explains how to integrate the **TestDriver CLI** with the **Jira GitH
42
42
 
43
43
  Here's a complete workflow that integrates TestDriver and Jira:
44
44
 
45
- ### Workflow File: `.github/workflows/testdriver-jira.yaml`
45
+ ### Workflow File:
46
46
 
47
- ```yaml [expandable]
47
+ ```yaml .github/workflows/testdriver-jira.yaml [expandable]
48
48
  name: TestDriver with Jira Integration
49
49
 
50
50
  on:
@@ -69,10 +69,11 @@ jobs:
69
69
 
70
70
  - name: Run TestDriver
71
71
  id: testdriver
72
+ shell: powershell
72
73
  run: |
73
74
  $exitCode = 0
74
75
  try {
75
- npx testdriverai@latest run testdriver/test.yaml --headless --key $env:TD_API_KEY --output="testdriver-output.txt"
76
+ npx testdriverai@latest run testdriver/test.yaml --summary="testdriver-summary.txt"
76
77
  } catch {
77
78
  $exitCode = $LASTEXITCODE
78
79
  }
@@ -86,22 +87,21 @@ jobs:
86
87
  }
87
88
  env:
88
89
  TD_API_KEY: ${{ secrets.TD_API_KEY }}
89
- shell: powershell
90
90
 
91
91
  - name: Check for Test Failures
92
92
  id: check-failures
93
+ shell: powershell
93
94
  run: |
94
95
  if ("${{ steps.testdriver.outputs.success }}" -eq "false") {
95
96
  echo "TestDriver tests failed."
96
97
  echo "failure=true" >> $env:GITHUB_ENV
97
98
 
98
99
  # Copy the output file for Jira ticket
99
- Copy-Item testdriver-output.txt failure-details.txt
100
+ Copy-Item testdriver-summary.txt failure-details.txt
100
101
  } else {
101
102
  echo "All tests passed."
102
103
  echo "failure=false" >> $env:GITHUB_ENV
103
104
  }
104
- shell: powershell
105
105
 
106
106
  - name: Upload test results
107
107
  if: always()
@@ -109,7 +109,7 @@ jobs:
109
109
  with:
110
110
  name: testdriver-results
111
111
  path: |
112
- testdriver-output.txt
112
+ testdriver-summary.txt
113
113
  failure-details.txt
114
114
 
115
115
  create-jira-ticket:
@@ -152,15 +152,14 @@ jobs:
152
152
 
153
153
  ### 1. **Run Tests with TestDriver CLI**
154
154
 
155
- The TestDriver CLI runs your tests in headless mode using the `--headless` flag. The `--output` flag specifies where to save the test results for later use in Jira tickets.
155
+ This step runs the TestDriver CLI with the `testdriver/test.yaml` file.
156
156
 
157
- ```yaml
157
+ ```yaml testdriver/test.yaml
158
158
  - name: Run TestDriver
159
159
  id: testdriver
160
- run: npx testdriverai@latest run testdriver/test.yaml --headless --key $env:TD_API_KEY --output="testdriver-output.txt"
160
+ run: npx testdriverai@latest run testdriver/test.yaml
161
161
  env:
162
162
  TD_API_KEY: ${{ secrets.TD_API_KEY }}
163
- shell: powershell
164
163
  ```
165
164
 
166
165
  ---
@@ -169,7 +168,7 @@ The TestDriver CLI runs your tests in headless mode using the `--headless` flag.
169
168
 
170
169
  This step checks the exit code and success status from the TestDriver CLI run. If the tests failed, it sets an environment variable (`failure=true`) to trigger the Jira ticket creation step and prepares the output file for the Jira ticket.
171
170
 
172
- ```yaml
171
+ ```yaml testdriver/test.yaml
173
172
  - name: Check for Test Failures
174
173
  id: check-failures
175
174
  run: |
@@ -195,7 +194,7 @@ If any tests failed, the `create-jira-ticket` job uses the `atlassian/gajira-cre
195
194
  - **Summary**: A brief description of the failure with repository information.
196
195
  - **Description**: Detailed information about the failure, including repository details, workflow run links, and the captured test output.
197
196
 
198
- ```yaml
197
+ ```yaml testdriver/test.yaml
199
198
  - name: Create Jira Ticket
200
199
  uses: atlassian/gajira-create@v3
201
200
  with:
@@ -231,65 +230,3 @@ Add the following secrets to your GitHub repository:
231
230
  4. **`JIRA_USERNAME`**: Your Jira account email.
232
231
 
233
232
  ---
234
-
235
- ## Lifecycle files
236
-
237
- TestDriver supports lifecycle files to customize test execution at different phases. These files replace the previous `prerun` parameter from the GitHub Action and provide more comprehensive control over the test environment.
238
-
239
- The main lifecycle files are:
240
-
241
- - **`lifecycle/provision.yaml`**: Executed when a new sandbox is created
242
- - **`lifecycle/prerun.yaml`**: Executed before tests run (replaces the old `prerun` parameter)
243
- - **`lifecycle/postrun.yaml`**: Executed after tests complete
244
-
245
- <Note>
246
- These lifecycle files should be placed in your repository's `lifecycle/`
247
- directory and will be automatically executed by TestDriver during the
248
- appropriate phases.
249
- </Note>
250
-
251
- For detailed information about lifecycle files, including complete examples and best practices, see the [Lifecycle Files guide](/guide/lifecycle).
252
-
253
- ---
254
-
255
- ## Example Jira ticket
256
-
257
- ### Summary:
258
-
259
- `TestDriver Test Failure in mycompany/myproject`
260
-
261
- ### Description:
262
-
263
- ```
264
- A test failure occurred during the TestDriver workflow.
265
-
266
- **Repository**: mycompany/myproject
267
- **Branch**: refs/heads/main
268
- **Commit**: abc123def456
269
- **Workflow Run**: https://github.com/mycompany/myproject/actions/runs/123456789
270
-
271
- **Failure Details**:
272
- ```
273
-
274
- TestDriver CLI execution failed
275
- Error: Test 'Login Test' failed - element not found
276
- Exit code: 1
277
-
278
- ```
279
-
280
- Please investigate the issue and resolve it promptly.
281
-
282
- ```
283
-
284
- ---
285
-
286
- ## Benefits of this workflow
287
-
288
- 1. **Automated Issue Tracking**: Automatically creates Jira tickets for test failures, ensuring no issues are overlooked.
289
- 2. **Detailed Context**: Includes test output, repository information, and workflow run links in the Jira ticket for easier debugging.
290
- 3. **Streamlined Workflow**: Integrates testing and issue tracking into a single automated pipeline.
291
- 4. **Flexible Lifecycle Management**: Supports custom setup, provisioning, and cleanup through lifecycle files.
292
-
293
- ---
294
-
295
- By combining TestDriver CLI with Jira GitHub Actions, you can automate the process of tracking test failures, improving collaboration and ensuring faster resolution of issues.
@@ -15,20 +15,20 @@ npx testdriverai@latest <command> [options]
15
15
 
16
16
  ## Available commands
17
17
 
18
- | Command | Description |
19
- | ---------------------- | ------------------------------------------------------------ |
18
+ | Command | Description |
19
+ | :--------------------: | :----------------------------------------------------------- |
20
20
  | [`run`](/commands/run) | Executes a TestDriver test. |
21
- | `edit` | Launch interactive mode. |
22
- | `help` | Displays help information for the CLI or a specific command. |
21
+ | [`edit`](/commands/edit) | Launch interactive mode. |
22
+ | [`help`](/commands/help) | Displays help information for the CLI or a specific command. |
23
23
 
24
24
  ## Available Flags
25
25
 
26
26
  | Flag | Description |
27
- | ------------------- | ------------------------------------------------------------------------------------------ |
27
+ | :------------------ | :----------------------------------------------------------------------------------------- |
28
28
  | `--heal` | Launch exploratory mode and attemp to recover if an error or failing state is encountered. |
29
29
  | `--write` | Ovewrite test file with new commands resulting from agentic testing |
30
30
  | `--headless` | Run test without opening a browser window (useful for CI/CD environments) |
31
- | `--new-sandbox` | Create a new sandbox environment for the test run. |
31
+ | `--new` | Create a new sandbox environment for the test run. |
32
32
  | `--summary=<value>` | Output file where AI summary should be saved. |
33
33
 
34
34
  ## Example usage
@@ -18,29 +18,29 @@ The `exec` command allows you to execute custom Node.js scripts within your Test
18
18
 
19
19
  ## Arguments
20
20
 
21
- | Argument | Type | Description |
22
- | -------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
23
- | `lang` | `string` | The language of the script to execute. Supported values are `shell` and `js`. |
21
+ | Argument | Type | Description |
22
+ | :------: | :------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
23
+ | `lang` | `string` | The language of the script to execute. Supported values are `pwsh` and `js`. |
24
24
  | `output` | `string` | The variable name to store the result of the script. This variable can be accessed as `${OUTPUT.<var>}` in future steps. |
25
- | `silent` | `string` | Defaults to `false`. The command will print the output of the script. This is useful for suppressing unnecessary or private output in the test logs. This is useful for debugging. |
26
- | `code` | `string` | The script to execute on Windows systems. For `js`, the script must define the output as `result`. |
25
+ | `code` | `string` | The script to execute on Windows systems. For `js`, the script must define the output as `result`. |
26
+ | `silent` | `string` | Defaults to `false`. The command will print the output of the script. This is useful for suppressing unnecessary or private output in the test logs and it's useful for debugging. |
27
27
 
28
28
  ## Example usage
29
29
 
30
30
  This example demonstrates how to use the `exec` command to generate a TOTP (Time-based One-Time Password) using the `totp-generator` library.
31
31
 
32
- ```yaml
33
- version: 5.3.8
32
+ ```yaml otp-generator.yaml
33
+ version: 6.0.0
34
34
  steps:
35
35
  - commands:
36
36
  - command: exec
37
37
  lang: pwsh
38
- linux: |
38
+ code: |
39
39
  npm install totp-generator
40
40
  - command: exec
41
41
  lang: js
42
42
  output: totp
43
- linux: |
43
+ code: |
44
44
  const { TOTP } = require("totp-generator");
45
45
  let otp = TOTP.generate("JBSWY3DPEB3W64TMMQQQ").otp;
46
46
  console.log(otp);
@@ -51,19 +51,16 @@ steps:
51
51
 
52
52
  ## Additional details
53
53
 
54
- - The `exec` command now takes a `lang` argument and supports different operating systems (`linux`, `mac`, and `windows`).
55
- - Supported `lang` values are `js` or `shell`:
56
- - `js` code is executed in a Node.js VM on the host machine (for example the machine where your CI/CD runs, or your computer if using the local agent).
57
- - `shell` code is executed in the shell on target runner (which can be the cloud runner, local sandbox, or local machine, depending on where you run your tests).
58
- - Note: You can also use `shell` in [`prerun`](/guide/lifecycle-prerun) scripts to install npm packages if you need them.
59
- - Otherwise, the `shell` code can be used within test steps to launch applications or perform simple commands (like writing text to a file on the machine to perform a simple file upload).
60
- - Code specified in `linux`, `mac`, and `windows` is executed based on the platform of the runner machine.
54
+ - Supported `lang` values are `js` or `pwsh`:
55
+ - `js` code is executed in a Node.js [VM](https://nodejs.org/api/vm.html) internally on the host machine (for example the machine where your CI/CD runs, or your computer if using the local agent).
56
+ - `pwsh` code is executed in the shell on target runner (which can be the cloud runner, local sandbox, or local machine, depending on where you run your tests).
57
+ - **Note:** You can also use `pwsh` in [lifecycle](/guide/lifecycle) scripts to install npm packages if you need them.
58
+ - Otherwise, the `pwsh` code can be used within test steps to launch applications or perform simple commands (like writing text to a file on the machine to perform a simple file upload).
61
59
  - The `output`argument is assigned automatically by setting `result = somestringvalue` in the script you run.
62
60
 
63
61
  ## Protips
64
62
 
65
63
  - The `result` variable is already available in your script, overwrite it to store the output as shown in the examples.
66
- - Node.js code executes in the same context as the calling process on the host machine, using the [VM](https://nodejs.org/api/vm.html) module internally.
67
64
  - Do any handling of arrays or nested objects within your `js` script:
68
65
  - ✅ `result = users[1].profile.firstName`
69
66
  - ✅ `result = data.length > 0 ? data[0].userEmail : 'no user found'` if no data is found the value of output will be `null`
@@ -79,21 +76,19 @@ steps:
79
76
 
80
77
  ## Ways to use `exec`
81
78
 
82
- Here is an example using both `shell` and `js` contexts within a [`prerun.yaml`](guide/lifecycle-prerun) script:
79
+ Here is an example using both `pwsh` and `js` contexts within a `prerun.yaml` script which creates a temporary email account and automatically clicks links found in received emails.
83
80
 
84
81
  ```yaml ./lifecycle/prerun.yaml [expandable]
85
- version: 5.3.8
82
+ version: 6.0.0
86
83
  steps:
87
84
  - commands:
88
85
  - command: exec
89
86
  lang: pwsh
90
- silent: false
91
87
  code: |
92
88
  npm install @sendgrid/mail
93
89
  - command: exec
94
90
  lang: js
95
91
  output: accountData
96
- silent: false
97
92
  code: |
98
93
  const Mailjs = require("@cemalgnlts/mailjs");
99
94
  const mailjs = new Mailjs();
@@ -103,7 +98,6 @@ steps:
103
98
  - command: exec
104
99
  lang: js
105
100
  output: emailAddress
106
- silent: false
107
101
  code: |
108
102
  const accountData = ${OUTPUT.accountData};
109
103
  result = accountData.username
@@ -119,7 +113,6 @@ steps:
119
113
  commands:
120
114
  - command: exec
121
115
  lang: js
122
- silent: false
123
116
  code: |
124
117
  const Mailjs = require("@cemalgnlts/mailjs");
125
118
  const { JSDOM } = require('jsdom'); // To parse HTML and extract links
@@ -174,23 +167,24 @@ steps:
174
167
  getLatestEmailAndClickLinks();
175
168
  ```
176
169
 
177
- ### Using `exec` shell commands in a test file
170
+ ### Using `exec` pwsh commands in a test file
178
171
 
179
- In a test file, you can use the `shell` context directly:
172
+ In a test file, you can use the `pwsh` context directly:
180
173
 
181
- ```yaml testfile.yaml [expandable]
182
- version: 5.5.5
174
+ ```yaml calculator.yaml highlight={5-8} [expandable]
175
+ version: 6.0.0
183
176
  steps:
184
177
  - prompt: launch a calculator
185
178
  commands:
186
179
  - command: exec
187
180
  lang: pwsh
188
- code: start /B calc.exe
181
+ code: |
182
+ start /B calc.exe
189
183
  timeout /t 5
190
184
  - command: wait-for-text
191
185
  text: "calculator"
192
186
  timeout: 30000
193
- - prompt: /try performing the operation 2 + 2 = on the calculator that is opened
187
+ - prompt: performing the operation 2 + 2 = on the calculator that is opened
194
188
  commands:
195
189
  - command: focus-application
196
190
  name: galculator
@@ -212,14 +206,15 @@ steps:
212
206
 
213
207
  You can also save reusable snippets (like launching the calculator) to be inserted into a script later with the [`run`](/commands/run) command. That version would look something like this:
214
208
 
215
- ```yaml launchcalculator.yaml [expandable]
216
- version: 5.5.5
209
+ ```yaml snippets/launch-calculator.yaml [expandable]
210
+ version: 6.0.0
217
211
  steps:
218
212
  - prompt: launch a calculator
219
213
  commands:
220
214
  - command: exec
221
215
  lang: pwsh
222
- code: start /B calc.exe
216
+ code: |
217
+ start /B calc.exe
223
218
  timeout /t 5
224
219
  - command: wait-for-text
225
220
  text: "calculator"
@@ -228,14 +223,14 @@ steps:
228
223
 
229
224
  Then in the test:
230
225
 
231
- ```yaml {5-6} testfile.yaml [expandable]
232
- version: 5.5.5
226
+ ```yaml calculator.yaml highlight={5-6} [expandable]
227
+ version: 6.0.0
233
228
  steps:
234
229
  - prompt: launch a calculator
235
230
  commands:
236
231
  - command: run
237
- file: ./launchcalculator.yaml
238
- - prompt: /try performing the operation 2 + 2 = on the calculator that is opened
232
+ file: snippets/launch-calculator.yaml
233
+ - prompt: performing the operation 2 + 2 = on the calculator that is opened
239
234
  commands:
240
235
  - command: focus-application
241
236
  name: galculator
@@ -258,7 +253,7 @@ steps:
258
253
  This example will fail at runtime, so don't try to execute `js` context directly in a test file. Remember - use this in `prerun` to setup your test!
259
254
 
260
255
  ```yaml badtestfile.yaml [expandable]
261
- version: 5.5.5
256
+ version: 6.0.0
262
257
  commands:
263
258
  - command: exec
264
259
  lang: pwsh
@@ -3,11 +3,12 @@ title: "focus-application"
3
3
  sidebarTitle: "focus-application"
4
4
  description: "Bring a specific application window to the foreground."
5
5
  icon: "window-restore"
6
+ mode: "wide"
6
7
  ---
7
8
 
8
9
  ## Description
9
10
 
10
- The `focus-application` command brings a specific application window to the foreground. This ensures that subsequent commands interact with the correct application during a test.
11
+ The `focus-application` command displays a specific application window to the foreground. This ensures that subsequent commands interact with the correct application during a test.
11
12
 
12
13
  ## Arguments
13
14
 
@@ -26,8 +27,18 @@ name: Google Chrome
26
27
 
27
28
  - Ensure the application name matches the exact name displayed in your operating system's task manager.
28
29
  - Use this command at the start of a test or before interacting with an application to avoid focus-related issues.
29
- - If the specified application isn't running, the command will fail. Ensure the application is open before using this command.
30
30
 
31
+ <Note>
32
+ If the specified application isn't running, the command will fail. Ensure the application is open before using this command.
33
+ For example, to launch chrome try using the exec command:
34
+
35
+ ```yaml
36
+ - command: exec
37
+ lang: pwsh
38
+ code: start chrome
39
+ ```
40
+
41
+ </Note>
31
42
  ## Notes
32
43
 
33
44
  - The `focus-application` command is useful for multi-application workflows where you need to switch between different apps during a test.