@testdriverai/agent 7.11.240-test → 7.11.241-test

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 (52) hide show
  1. package/ai/skills/testdriver-agent/SKILL.md +174 -91
  2. package/ai/skills/testdriver-assert/SKILL.md +73 -269
  3. package/ai/skills/testdriver-aws-setup/SKILL.md +194 -312
  4. package/ai/skills/testdriver-bring-your-own-machine/SKILL.md +137 -204
  5. package/ai/skills/testdriver-cache/SKILL.md +142 -149
  6. package/ai/skills/testdriver-caching/SKILL.md +97 -87
  7. package/ai/skills/testdriver-captcha/SKILL.md +126 -111
  8. package/ai/skills/testdriver-ci-cd/SKILL.md +153 -542
  9. package/ai/skills/testdriver-click/SKILL.md +74 -229
  10. package/ai/skills/testdriver-client/SKILL.md +175 -229
  11. package/ai/skills/testdriver-customizing-devices/SKILL.md +72 -250
  12. package/ai/skills/testdriver-dashcam/SKILL.md +71 -404
  13. package/ai/skills/testdriver-debugging-with-screenshots/SKILL.md +103 -369
  14. package/ai/skills/testdriver-double-click/SKILL.md +46 -67
  15. package/ai/skills/testdriver-errors/SKILL.md +102 -176
  16. package/ai/skills/testdriver-events/SKILL.md +170 -327
  17. package/ai/skills/testdriver-exec/SKILL.md +92 -256
  18. package/ai/skills/testdriver-extract/SKILL.md +69 -170
  19. package/ai/skills/testdriver-find/SKILL.md +140 -736
  20. package/ai/skills/testdriver-focus-application/SKILL.md +69 -246
  21. package/ai/skills/testdriver-generating-tests/SKILL.md +102 -136
  22. package/ai/skills/testdriver-hosted/SKILL.md +79 -143
  23. package/ai/skills/testdriver-hover/SKILL.md +62 -235
  24. package/ai/skills/testdriver-locating-elements/SKILL.md +71 -366
  25. package/ai/skills/testdriver-making-assertions/SKILL.md +114 -72
  26. package/ai/skills/testdriver-mcp-setup/SKILL.md +79 -62
  27. package/ai/skills/testdriver-mouse-down/SKILL.md +46 -124
  28. package/ai/skills/testdriver-mouse-up/SKILL.md +45 -128
  29. package/ai/skills/testdriver-options/SKILL.md +73 -46
  30. package/ai/skills/testdriver-parse/SKILL.md +95 -184
  31. package/ai/skills/testdriver-performing-actions/SKILL.md +101 -91
  32. package/ai/skills/testdriver-press-keys/SKILL.md +59 -299
  33. package/ai/skills/testdriver-provision/SKILL.md +135 -179
  34. package/ai/skills/testdriver-quickstart/SKILL.md +24 -8
  35. package/ai/skills/testdriver-quickstart-claude/SKILL.md +84 -0
  36. package/ai/skills/testdriver-quickstart-github/SKILL.md +62 -32
  37. package/ai/skills/testdriver-quickstart-manual/SKILL.md +59 -32
  38. package/ai/skills/testdriver-quickstart-vscode/SKILL.md +96 -0
  39. package/ai/skills/testdriver-redraw/SKILL.md +100 -164
  40. package/ai/skills/testdriver-reusable-code/SKILL.md +95 -199
  41. package/ai/skills/testdriver-right-click/SKILL.md +45 -88
  42. package/ai/skills/testdriver-screenshot/SKILL.md +47 -201
  43. package/ai/skills/testdriver-screenshots/SKILL.md +86 -136
  44. package/ai/skills/testdriver-scroll/SKILL.md +71 -154
  45. package/ai/skills/testdriver-secrets/SKILL.md +94 -90
  46. package/ai/skills/testdriver-self-hosted/SKILL.md +82 -140
  47. package/ai/skills/testdriver-test-results-json/SKILL.md +165 -202
  48. package/ai/skills/testdriver-type/SKILL.md +56 -304
  49. package/ai/skills/testdriver-variables/SKILL.md +119 -80
  50. package/ai/skills/testdriver-wait/SKILL.md +31 -29
  51. package/ai/skills/testdriver-what-is-testdriver/SKILL.md +80 -32
  52. package/package.json +1 -1
@@ -1,158 +1,173 @@
1
1
  ---
2
2
  name: testdriver:captcha
3
- description: Solve captchas using 2captcha service
3
+ description: Solve a reCAPTCHA, hCaptcha, or Cloudflare Turnstile on the page with the 2captcha service.
4
4
  ---
5
5
  <!-- Generated from captcha.mdx. DO NOT EDIT. -->
6
6
 
7
- # Captcha Solving
8
-
9
- TestDriver can solve captchas automatically during your tests. It uses the 2captcha service. This feature works on **Linux** sandboxes and **Windows** sandboxes.
10
-
11
- ## Quick Start
12
-
7
+ Solve a captcha on the current page so your test can get past it. TestDriver uses the [2captcha](https://2captcha.com) solving service, so you need a 2captcha account and API key.
13
8
 
14
9
  ```javascript
15
- const result = await testdriver.captcha({
16
- apiKey: process.env.TWOCAPTCHA_API_KEY,
17
- });
18
-
19
- console.log(result.success); // true
20
- console.log(result.token); // The solved captcha token
10
+ const result = await testdriver.captcha({ apiKey: process.env.TWOCAPTCHA_API_KEY });
21
11
  ```
22
12
 
23
- That is all. TestDriver does these automatically:
24
- - Finds the captcha type on the page
25
- - Gets the sitekey
26
- - Solves the captcha with 2captcha
27
- - Puts the token into the page
28
- - Starts the callbacks
13
+ With no other options, `captcha()`:
29
14
 
30
- ## Supported Captcha Types
15
+ - Finds the captcha on the page and reads its sitekey.
16
+ - Sends it to 2captcha and waits for the solution.
17
+ - Puts the token into the page and calls the page's captcha callbacks.
18
+ - Clicks the form's submit button.
31
19
 
32
- | Type | Auto-Detected | Notes |
33
- |------|---------------|-------|
34
- | reCAPTCHA v2 | ✅ | Including invisible |
35
- | reCAPTCHA v3 | ✅ | Action is auto-detected |
36
- | hCaptcha | ✅ | |
37
- | Cloudflare Turnstile | ✅ | |
20
+ It works on Linux and Windows sandboxes, in Chrome opened with [`provision.chrome()`](/provision#chrome-options).
38
21
 
39
- ## Getting a 2captcha API Key
22
+ ## Signature
40
23
 
41
- 1. Sign up at [2captcha.com](https://2captcha.com)
42
- 2. Add funds to your account
43
- 3. Copy your API key from the dashboard
44
-
45
- ## Configuration Options
46
-
47
- ```javascript
48
- const result = await testdriver.captcha({
49
- // Required
50
- apiKey: '2CAPTCHA_API_KEY',
51
-
52
- // Optional - usually auto-detected
53
- sitekey: '6Le...', // Override auto-detected sitekey
54
- type: 'recaptcha_v3', // Override auto-detected type
55
- action: 'submit', // reCAPTCHA v3 action
56
-
57
- // Timing
58
- timeout: 120000, // Max wait time (default: 120s)
59
- pollInterval: 5000, // Poll interval (default: 5s)
60
- });
24
+ ```typescript
25
+ testdriver.captcha(options: CaptchaOptions): Promise<CaptchaResult>
61
26
  ```
62
27
 
63
- ## Full Example
64
-
65
- ```javascript
66
- import { describe, expect, it } from "vitest";
67
- import { TestDriver } from "testdriver";
68
-
69
- describe("Checkout flow", () => {
70
- it("should complete checkout with captcha", async (context) => {
28
+ ## Parameters
29
+
30
+ <ParamField path="options" type="CaptchaOptions" required>
31
+ <Expandable title="properties">
32
+ <ParamField path="apiKey" type="string" required>
33
+ Your 2captcha API key. `captcha()` throws if it's missing.
34
+ </ParamField>
35
+ <ParamField path="sitekey" type="string">
36
+ The captcha's sitekey. When you leave it out, TestDriver finds the captcha and its type on the page. When you set it, also set `type`.
37
+ </ParamField>
38
+ <ParamField path="type" type="string" default="recaptcha_v3">
39
+ `'recaptcha_v2'`, `'recaptcha_v3'`, `'hcaptcha'`, or `'turnstile'`. Only used when you set `sitekey`. Otherwise the detected type is used.
40
+ </ParamField>
41
+ <ParamField path="action" type="string" default="verify">
42
+ The reCAPTCHA v3 action. Detected from the page when possible.
43
+ </ParamField>
44
+ <ParamField path="autoSubmit" type="boolean" default="true">
45
+ Click the form's submit button after the captcha is solved.
46
+ </ParamField>
47
+ <ParamField path="timeout" type="number" default="120000">
48
+ How long to wait for 2captcha's solution, in milliseconds.
49
+ </ParamField>
50
+ <ParamField path="pollInterval" type="number" default="5000">
51
+ How often to check 2captcha for the solution, in milliseconds.
52
+ </ParamField>
53
+ </Expandable>
54
+ </ParamField>
55
+
56
+ ### Captchas it detects
57
+
58
+ | Captcha | Detected from |
59
+ | --- | --- |
60
+ | reCAPTCHA v2, including invisible | The `g-recaptcha` element |
61
+ | reCAPTCHA v3 | `grecaptcha.execute()` or the `render=` script parameter, including the action |
62
+ | hCaptcha | The `h-captcha` element |
63
+ | Cloudflare Turnstile | The `cf-turnstile` element |
64
+
65
+ ## Returns
66
+
67
+ <ResponseField name="CaptchaResult" type="object">
68
+ <Expandable title="properties">
69
+ <ResponseField name="success" type="boolean">
70
+ Whether the captcha was solved.
71
+ </ResponseField>
72
+ <ResponseField name="token" type="string | null">
73
+ The solved token.
74
+ </ResponseField>
75
+ <ResponseField name="message" type="string">
76
+ `"Captcha solved successfully"` or `"Captcha solving failed"`.
77
+ </ResponseField>
78
+ <ResponseField name="output" type="string">
79
+ The solver's full log, for debugging.
80
+ </ResponseField>
81
+ </Expandable>
82
+ </ResponseField>
83
+
84
+ ## Errors
85
+
86
+ `captcha()` throws when:
87
+
88
+ - `apiKey` is missing.
89
+ - No captcha is found on the page and you didn't set `sitekey`. The message is `Could not auto-detect captcha. Please provide sitekey manually.`
90
+ - The solver reports an error, for example a 2captcha error or a timeout. The message starts with `[captcha]`.
91
+
92
+ ## Examples
93
+
94
+ ### Solve a captcha before submitting a form
95
+
96
+ ```javascript tests/signup.test.mjs
97
+ import { describe, expect, it } from 'vitest';
98
+ import { TestDriver } from 'testdriverai/vitest/hooks';
99
+
100
+ describe('Signup', () => {
101
+ it('gets past the captcha', async (context) => {
71
102
  const testdriver = TestDriver(context);
103
+ await testdriver.provision.chrome({ url: 'https://example.com/signup' });
72
104
 
73
- // Navigate to checkout page
74
- await testdriver.provision.chrome({
75
- url: 'https://example.com/checkout',
76
- });
77
-
78
- // Fill out form
79
- await testdriver.type({ text: 'John Doe', selector: '#name' });
80
- await testdriver.type({ text: 'john@example.com', selector: '#email' });
81
-
82
- // Solve the captcha
83
- const result = await testdriver.captcha({
84
- apiKey: process.env.TWOCAPTCHA_API_KEY,
85
- });
105
+ await testdriver.find('Email input field').click();
106
+ await testdriver.type('user@example.com');
86
107
 
108
+ // Solves the captcha, then clicks the form's submit button
109
+ const result = await testdriver.captcha({ apiKey: process.env.TWOCAPTCHA_API_KEY });
87
110
  expect(result.success).toBe(true);
88
111
 
89
- // Submit the form
90
- await testdriver.click({ selector: '#submit' });
91
-
92
- // Verify success
93
- await testdriver.find({ text: 'Order confirmed' });
94
- }, 180000);
112
+ await testdriver.assert('a confirmation message is shown');
113
+ });
95
114
  });
96
115
  ```
97
116
 
98
- ## Environment Variables
99
-
100
- You can set your API key as an environment variable:
117
+ ### Submit the form yourself
101
118
 
102
- ```bash
103
- export TWOCAPTCHA_API_KEY=your_api_key_here
119
+ ```javascript
120
+ await testdriver.captcha({ apiKey: process.env.TWOCAPTCHA_API_KEY, autoSubmit: false });
121
+ await testdriver.find('Create account button').click();
104
122
  ```
105
123
 
106
- Then use it in your tests:
124
+ ### Set the sitekey and type
107
125
 
108
126
  ```javascript
109
- const result = await testdriver.captcha({
127
+ await testdriver.captcha({
110
128
  apiKey: process.env.TWOCAPTCHA_API_KEY,
129
+ sitekey: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI',
130
+ type: 'recaptcha_v2',
111
131
  });
112
132
  ```
113
133
 
114
- ### GitHub Actions
134
+ ## Set up the API key
115
135
 
116
- Add the key to your repository secrets and expose it in your workflow:
136
+ Sign up at [2captcha.com](https://2captcha.com), add funds, and copy your API key. Keep it out of your test code: put it in `.env` locally, and in a secret in CI.
117
137
 
118
- ```yaml
119
- - name: Run Tests
120
- run: vitest run
138
+ ```bash .env
139
+ TWOCAPTCHA_API_KEY=your_2captcha_key
140
+ ```
141
+
142
+ ```yaml .github/workflows/testdriver.yml
143
+ - name: Run TestDriver tests
144
+ run: npx vitest run
121
145
  env:
122
146
  TWOCAPTCHA_API_KEY: ${{ secrets.TWOCAPTCHA_API_KEY }}
123
147
  ```
124
148
 
125
- ## How It Works
126
-
127
- 1. **Detection**: Scans the page for captcha elements (`data-sitekey`, script tags, etc.)
128
- 2. **Submit**: Sends the captcha challenge to 2captcha's solving service
129
- 3. **Poll**: Waits for human solvers to complete the captcha
130
- 4. **Inject**: Injects the solved token into the page's hidden fields
131
- 5. **Callback**: Triggers any JavaScript callbacks the page expects
132
-
133
149
  ## Troubleshooting
134
150
 
135
- ### "Could not auto-detect captcha"
151
+ <AccordionGroup>
152
+ <Accordion title="Could not auto-detect captcha">
153
+
154
+ The captcha wasn't on the page when `captcha()` ran. Wait for it to load first, for example with `find()` and a `timeout`. If it still isn't detected, pass `sitekey` and `type`.
136
155
 
137
- The captcha element wasn't found on the page. Try:
138
- - Waiting for the page to fully load before calling `captcha()`
139
- - Providing the `sitekey` and `type` manually
156
+ </Accordion>
157
+ <Accordion title="The solve times out">
140
158
 
141
- ### Timeout errors
159
+ 2captcha's workers usually take 10 to 30 seconds. Raise `timeout`, and check that your 2captcha account has funds.
142
160
 
143
- Captcha solving typically takes 10-30 seconds. If you're getting timeouts:
144
- - Increase the `timeout` option
145
- - Check your 2captcha balance
146
- - Verify the captcha type is correct
161
+ </Accordion>
162
+ <Accordion title="The site rejects the token">
147
163
 
148
- ### Token not working
164
+ Check that `type` matches the captcha on the page. For reCAPTCHA v3, check that `action` matches the action the site uses.
149
165
 
150
- Some sites validate tokens immediately. Make sure:
151
- - The token is injected before form submission
152
- - The captcha type matches what the site expects
153
- - For reCAPTCHA v3, the `action` parameter matches the site's expected action
166
+ </Accordion>
167
+ </AccordionGroup>
154
168
 
155
- ## Requirements
169
+ ## Related
156
170
 
157
- - Chrome must be launched with remote debugging enabled (automatic on all sandboxes)
158
- - A valid 2captcha API key with sufficient balance
171
+ - [Launch apps](/provision): open Chrome before solving
172
+ - [Secrets](/secrets): keep API keys out of your tests
173
+ - [type()](/type) and [find()](/find): fill in the rest of the form