@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.
- package/ai/skills/testdriver-agent/SKILL.md +174 -91
- package/ai/skills/testdriver-assert/SKILL.md +73 -269
- package/ai/skills/testdriver-aws-setup/SKILL.md +194 -312
- package/ai/skills/testdriver-bring-your-own-machine/SKILL.md +137 -204
- package/ai/skills/testdriver-cache/SKILL.md +142 -149
- package/ai/skills/testdriver-caching/SKILL.md +97 -87
- package/ai/skills/testdriver-captcha/SKILL.md +126 -111
- package/ai/skills/testdriver-ci-cd/SKILL.md +153 -542
- package/ai/skills/testdriver-click/SKILL.md +74 -229
- package/ai/skills/testdriver-client/SKILL.md +175 -229
- package/ai/skills/testdriver-customizing-devices/SKILL.md +72 -250
- package/ai/skills/testdriver-dashcam/SKILL.md +71 -404
- package/ai/skills/testdriver-debugging-with-screenshots/SKILL.md +103 -369
- package/ai/skills/testdriver-double-click/SKILL.md +46 -67
- package/ai/skills/testdriver-errors/SKILL.md +102 -176
- package/ai/skills/testdriver-events/SKILL.md +170 -327
- package/ai/skills/testdriver-exec/SKILL.md +92 -256
- package/ai/skills/testdriver-extract/SKILL.md +69 -170
- package/ai/skills/testdriver-find/SKILL.md +140 -736
- package/ai/skills/testdriver-focus-application/SKILL.md +69 -246
- package/ai/skills/testdriver-generating-tests/SKILL.md +102 -136
- package/ai/skills/testdriver-hosted/SKILL.md +79 -143
- package/ai/skills/testdriver-hover/SKILL.md +62 -235
- package/ai/skills/testdriver-locating-elements/SKILL.md +71 -366
- package/ai/skills/testdriver-making-assertions/SKILL.md +114 -72
- package/ai/skills/testdriver-mcp-setup/SKILL.md +79 -62
- package/ai/skills/testdriver-mouse-down/SKILL.md +46 -124
- package/ai/skills/testdriver-mouse-up/SKILL.md +45 -128
- package/ai/skills/testdriver-options/SKILL.md +73 -46
- package/ai/skills/testdriver-parse/SKILL.md +95 -184
- package/ai/skills/testdriver-performing-actions/SKILL.md +101 -91
- package/ai/skills/testdriver-press-keys/SKILL.md +59 -299
- package/ai/skills/testdriver-provision/SKILL.md +135 -179
- package/ai/skills/testdriver-quickstart/SKILL.md +24 -8
- package/ai/skills/testdriver-quickstart-claude/SKILL.md +84 -0
- package/ai/skills/testdriver-quickstart-github/SKILL.md +62 -32
- package/ai/skills/testdriver-quickstart-manual/SKILL.md +59 -32
- package/ai/skills/testdriver-quickstart-vscode/SKILL.md +96 -0
- package/ai/skills/testdriver-redraw/SKILL.md +100 -164
- package/ai/skills/testdriver-reusable-code/SKILL.md +95 -199
- package/ai/skills/testdriver-right-click/SKILL.md +45 -88
- package/ai/skills/testdriver-screenshot/SKILL.md +47 -201
- package/ai/skills/testdriver-screenshots/SKILL.md +86 -136
- package/ai/skills/testdriver-scroll/SKILL.md +71 -154
- package/ai/skills/testdriver-secrets/SKILL.md +94 -90
- package/ai/skills/testdriver-self-hosted/SKILL.md +82 -140
- package/ai/skills/testdriver-test-results-json/SKILL.md +165 -202
- package/ai/skills/testdriver-type/SKILL.md +56 -304
- package/ai/skills/testdriver-variables/SKILL.md +119 -80
- package/ai/skills/testdriver-wait/SKILL.md +31 -29
- package/ai/skills/testdriver-what-is-testdriver/SKILL.md +80 -32
- package/package.json +1 -1
|
@@ -1,158 +1,173 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: testdriver:captcha
|
|
3
|
-
description: Solve
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
22
|
+
## Signature
|
|
40
23
|
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
##
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
74
|
-
await testdriver.
|
|
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
|
-
|
|
90
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
You can set your API key as an environment variable:
|
|
117
|
+
### Submit the form yourself
|
|
101
118
|
|
|
102
|
-
```
|
|
103
|
-
|
|
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
|
-
|
|
124
|
+
### Set the sitekey and type
|
|
107
125
|
|
|
108
126
|
```javascript
|
|
109
|
-
|
|
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
|
-
|
|
134
|
+
## Set up the API key
|
|
115
135
|
|
|
116
|
-
|
|
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
|
-
```
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
- Providing the `sitekey` and `type` manually
|
|
156
|
+
</Accordion>
|
|
157
|
+
<Accordion title="The solve times out">
|
|
140
158
|
|
|
141
|
-
|
|
159
|
+
2captcha's workers usually take 10 to 30 seconds. Raise `timeout`, and check that your 2captcha account has funds.
|
|
142
160
|
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
|
|
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
|
-
|
|
151
|
-
|
|
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
|
-
##
|
|
169
|
+
## Related
|
|
156
170
|
|
|
157
|
-
-
|
|
158
|
-
-
|
|
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
|