testdriverai 7.3.12 → 7.3.13
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/skills/testdriver:ai/SKILL.md +204 -0
- package/.github/skills/testdriver:assert/SKILL.md +284 -0
- package/.github/skills/testdriver:aws-setup/SKILL.md +515 -0
- package/.github/skills/testdriver:caching/SKILL.md +124 -0
- package/.github/skills/testdriver:captcha/SKILL.md +159 -0
- package/.github/skills/testdriver:ci-cd/SKILL.md +602 -0
- package/.github/skills/testdriver:click/SKILL.md +286 -0
- package/.github/skills/testdriver:client/SKILL.md +339 -0
- package/.github/skills/testdriver:cloud/SKILL.md +119 -0
- package/.github/skills/testdriver:customizing-devices/SKILL.md +153 -0
- package/.github/skills/testdriver:dashcam/SKILL.md +418 -0
- package/.github/skills/testdriver:debugging-with-screenshots/SKILL.md +271 -0
- package/.github/skills/testdriver:device-config/SKILL.md +317 -0
- package/.github/skills/testdriver:double-click/SKILL.md +102 -0
- package/.github/skills/testdriver:elements/SKILL.md +605 -0
- package/.github/skills/testdriver:enterprise/SKILL.md +114 -0
- package/.github/skills/testdriver:examples/SKILL.md +7 -0
- package/.github/skills/testdriver:exec/SKILL.md +345 -0
- package/.github/skills/testdriver:find/SKILL.md +721 -0
- package/.github/skills/testdriver:focus-application/SKILL.md +293 -0
- package/.github/skills/testdriver:generating-tests/SKILL.md +36 -0
- package/.github/skills/testdriver:hover/SKILL.md +278 -0
- package/.github/skills/testdriver:locating-elements/SKILL.md +71 -0
- package/.github/skills/testdriver:making-assertions/SKILL.md +32 -0
- package/.github/skills/testdriver:mcp-workflow/SKILL.md +410 -0
- package/.github/skills/testdriver:mouse-down/SKILL.md +161 -0
- package/.github/skills/testdriver:mouse-up/SKILL.md +164 -0
- package/.github/skills/testdriver:performing-actions/SKILL.md +51 -0
- package/.github/skills/testdriver:press-keys/SKILL.md +348 -0
- package/.github/skills/testdriver:quickstart/SKILL.md +161 -0
- package/.github/skills/testdriver:reusable-code/SKILL.md +240 -0
- package/.github/skills/testdriver:right-click/SKILL.md +123 -0
- package/.github/skills/testdriver:running-tests/SKILL.md +181 -0
- package/.github/skills/testdriver:screenshot/SKILL.md +167 -0
- package/.github/skills/testdriver:scroll/SKILL.md +299 -0
- package/.github/skills/testdriver:secrets/SKILL.md +115 -0
- package/.github/skills/testdriver:self-hosted/SKILL.md +65 -0
- package/.github/skills/testdriver:test-writer/SKILL.md +451 -0
- package/.github/skills/testdriver:testdriver/SKILL.md +523 -0
- package/.github/skills/testdriver:testdriver-mechanic/SKILL.md +165 -0
- package/.github/skills/testdriver:type/SKILL.md +357 -0
- package/.github/skills/testdriver:variables/SKILL.md +111 -0
- package/.github/skills/testdriver:waiting-for-elements/SKILL.md +66 -0
- package/.github/skills/testdriver:what-is-testdriver/SKILL.md +54 -0
- package/.github/workflows/acceptance-windows-scheduled.yaml +6 -1
- package/.github/workflows/acceptance.yaml +0 -36
- package/.github/workflows/update-examples.yaml +53 -0
- package/CHANGELOG.md +4 -0
- package/agent/events.js +1 -0
- package/agent/index.js +8 -0
- package/agent/lib/commands.js +48 -29
- package/agent/lib/redraw.js +3 -1
- package/agent/lib/sandbox.js +166 -14
- package/agent/lib/sdk.js +142 -3
- package/agent/lib/system.js +4 -6
- package/ai/skills/testdriver:ai/SKILL.md +204 -0
- package/ai/skills/testdriver:assert/SKILL.md +315 -0
- package/ai/skills/testdriver:aws-setup/SKILL.md +448 -0
- package/ai/skills/testdriver:caching/SKILL.md +124 -0
- package/ai/skills/testdriver:captcha/SKILL.md +159 -0
- package/ai/skills/testdriver:ci-cd/SKILL.md +602 -0
- package/ai/skills/testdriver:click/SKILL.md +286 -0
- package/ai/skills/testdriver:client/SKILL.md +372 -0
- package/ai/skills/testdriver:cloud/SKILL.md +119 -0
- package/ai/skills/testdriver:customizing-devices/SKILL.md +153 -0
- package/ai/skills/testdriver:dashcam/SKILL.md +418 -0
- package/ai/skills/testdriver:debugging-with-screenshots/SKILL.md +401 -0
- package/ai/skills/testdriver:device-config/SKILL.md +317 -0
- package/ai/skills/testdriver:double-click/SKILL.md +102 -0
- package/ai/skills/testdriver:elements/SKILL.md +605 -0
- package/ai/skills/testdriver:enterprise/SKILL.md +114 -0
- package/ai/skills/testdriver:examples/SKILL.md +7 -0
- package/ai/skills/testdriver:exec/SKILL.md +345 -0
- package/ai/skills/testdriver:find/SKILL.md +745 -0
- package/ai/skills/testdriver:focus-application/SKILL.md +293 -0
- package/ai/skills/testdriver:generating-tests/SKILL.md +36 -0
- package/ai/skills/testdriver:hover/SKILL.md +278 -0
- package/ai/skills/testdriver:locating-elements/SKILL.md +71 -0
- package/ai/skills/testdriver:making-assertions/SKILL.md +32 -0
- package/ai/skills/testdriver:mcp-workflow/SKILL.md +410 -0
- package/ai/skills/testdriver:mouse-down/SKILL.md +161 -0
- package/ai/skills/testdriver:mouse-up/SKILL.md +164 -0
- package/ai/skills/testdriver:ocr/SKILL.md +235 -0
- package/ai/skills/testdriver:performing-actions/SKILL.md +51 -0
- package/ai/skills/testdriver:press-keys/SKILL.md +348 -0
- package/ai/skills/testdriver:quickstart/SKILL.md +146 -0
- package/ai/skills/testdriver:reusable-code/SKILL.md +240 -0
- package/ai/skills/testdriver:right-click/SKILL.md +123 -0
- package/ai/skills/testdriver:running-tests/SKILL.md +185 -0
- package/ai/skills/testdriver:screenshot/SKILL.md +248 -0
- package/ai/skills/testdriver:scroll/SKILL.md +335 -0
- package/ai/skills/testdriver:secrets/SKILL.md +115 -0
- package/ai/skills/testdriver:self-hosted/SKILL.md +65 -0
- package/ai/skills/testdriver:test-writer/SKILL.md +451 -0
- package/ai/skills/testdriver:testdriver/SKILL.md +631 -0
- package/ai/skills/testdriver:testdriver-mechanic/SKILL.md +165 -0
- package/ai/skills/testdriver:type/SKILL.md +357 -0
- package/ai/skills/testdriver:variables/SKILL.md +111 -0
- package/ai/skills/testdriver:waiting-for-elements/SKILL.md +66 -0
- package/ai/skills/testdriver:what-is-testdriver/SKILL.md +54 -0
- package/debugger/index.html +12 -2
- package/docs/v7/examples/scroll-keyboard.mdx +1 -1
- package/docs/v7/find.mdx +1 -0
- package/examples/config.mjs +1 -1
- package/examples/findall-coffee-icons.test.mjs +42 -0
- package/examples/flake-diffthreshold-001.test.mjs +9 -0
- package/examples/flake-diffthreshold-01.test.mjs +9 -0
- package/examples/flake-diffthreshold-05.test.mjs +9 -0
- package/examples/{z_flake-noredraw-cache.test.mjs → flake-noredraw-cache.test.mjs} +2 -2
- package/examples/{z_flake-noredraw-nocache.test.mjs → flake-noredraw-nocache.test.mjs} +2 -2
- package/examples/{z_flake-redraw-cache.test.mjs → flake-redraw-cache.test.mjs} +2 -2
- package/examples/{z_flake-redraw-nocache.test.mjs → flake-redraw-nocache.test.mjs} +2 -2
- package/examples/flake-rocket-match.test.mjs +30 -0
- package/examples/{z_flake-shared.mjs → flake-shared.mjs} +2 -2
- package/examples/parse.test.mjs +19 -0
- package/examples/scroll-keyboard.test.mjs +1 -1
- package/interfaces/cli/lib/base.js +6 -0
- package/interfaces/logger.js +51 -13
- package/interfaces/vitest-plugin.mjs +137 -0
- package/lib/core/index.d.ts +22 -0
- package/lib/init-project.js +105 -6
- package/lib/vitest/hooks.mjs +2 -5
- package/lib/vitest/setup-disable-defender.mjs +52 -0
- package/package.json +2 -1
- package/sdk-log-formatter.js +90 -0
- package/sdk.d.ts +88 -51
- package/sdk.js +126 -18
- package/setup/aws/disable-defender.sh +42 -0
- package/vitest.config.mjs +1 -3
- package/examples/z_flake-diffthreshold-001.test.mjs +0 -9
- package/examples/z_flake-diffthreshold-01.test.mjs +0 -9
- package/examples/z_flake-diffthreshold-05.test.mjs +0 -9
- /package/{examples → manual}/captcha-api.test.mjs +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testdriver:captcha
|
|
3
|
+
description: Solve captchas using 2captcha service
|
|
4
|
+
---
|
|
5
|
+
<!-- Generated from captcha.mdx. DO NOT EDIT. -->
|
|
6
|
+
|
|
7
|
+
# Captcha Solving
|
|
8
|
+
|
|
9
|
+
TestDriver can automatically solve captchas during your tests using the 2captcha service. This feature works on both **Linux** and **Windows** sandboxes.
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
```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
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
That's it! TestDriver will automatically:
|
|
24
|
+
- Detect the captcha type on the page
|
|
25
|
+
- Extract the sitekey
|
|
26
|
+
- Solve the captcha via 2captcha
|
|
27
|
+
- Inject the token into the page
|
|
28
|
+
- Trigger any callbacks
|
|
29
|
+
|
|
30
|
+
## Supported Captcha Types
|
|
31
|
+
|
|
32
|
+
| Type | Auto-Detected | Notes |
|
|
33
|
+
|------|---------------|-------|
|
|
34
|
+
| reCAPTCHA v2 | ✅ | Including invisible |
|
|
35
|
+
| reCAPTCHA v3 | ✅ | Action is auto-detected |
|
|
36
|
+
| hCaptcha | ✅ | |
|
|
37
|
+
| Cloudflare Turnstile | ✅ | |
|
|
38
|
+
|
|
39
|
+
## Getting a 2captcha API Key
|
|
40
|
+
|
|
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
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
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) => {
|
|
71
|
+
const testdriver = TestDriver(context);
|
|
72
|
+
|
|
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
|
+
});
|
|
86
|
+
|
|
87
|
+
expect(result.success).toBe(true);
|
|
88
|
+
|
|
89
|
+
// Submit the form
|
|
90
|
+
await testdriver.click({ selector: '#submit' });
|
|
91
|
+
|
|
92
|
+
// Verify success
|
|
93
|
+
await testdriver.find({ text: 'Order confirmed' });
|
|
94
|
+
}, 180000);
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Environment Variables
|
|
99
|
+
|
|
100
|
+
You can set your API key as an environment variable:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
export TWOCAPTCHA_API_KEY=your_api_key_here
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Then use it in your tests:
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
```javascript
|
|
110
|
+
const result = await testdriver.captcha({
|
|
111
|
+
apiKey: process.env.TWOCAPTCHA_API_KEY,
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### GitHub Actions
|
|
116
|
+
|
|
117
|
+
Add the key to your repository secrets and expose it in your workflow:
|
|
118
|
+
|
|
119
|
+
```yaml
|
|
120
|
+
- name: Run Tests
|
|
121
|
+
run: vitest run
|
|
122
|
+
env:
|
|
123
|
+
TWOCAPTCHA_API_KEY: ${{ secrets.TWOCAPTCHA_API_KEY }}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## How It Works
|
|
127
|
+
|
|
128
|
+
1. **Detection**: Scans the page for captcha elements (`data-sitekey`, script tags, etc.)
|
|
129
|
+
2. **Submit**: Sends the captcha challenge to 2captcha's solving service
|
|
130
|
+
3. **Poll**: Waits for human solvers to complete the captcha
|
|
131
|
+
4. **Inject**: Injects the solved token into the page's hidden fields
|
|
132
|
+
5. **Callback**: Triggers any JavaScript callbacks the page expects
|
|
133
|
+
|
|
134
|
+
## Troubleshooting
|
|
135
|
+
|
|
136
|
+
### "Could not auto-detect captcha"
|
|
137
|
+
|
|
138
|
+
The captcha element wasn't found on the page. Try:
|
|
139
|
+
- Waiting for the page to fully load before calling `captcha()`
|
|
140
|
+
- Providing the `sitekey` and `type` manually
|
|
141
|
+
|
|
142
|
+
### Timeout errors
|
|
143
|
+
|
|
144
|
+
Captcha solving typically takes 10-30 seconds. If you're getting timeouts:
|
|
145
|
+
- Increase the `timeout` option
|
|
146
|
+
- Check your 2captcha balance
|
|
147
|
+
- Verify the captcha type is correct
|
|
148
|
+
|
|
149
|
+
### Token not working
|
|
150
|
+
|
|
151
|
+
Some sites validate tokens immediately. Make sure:
|
|
152
|
+
- The token is injected before form submission
|
|
153
|
+
- The captcha type matches what the site expects
|
|
154
|
+
- For reCAPTCHA v3, the `action` parameter matches the site's expected action
|
|
155
|
+
|
|
156
|
+
## Requirements
|
|
157
|
+
|
|
158
|
+
- Chrome must be launched with remote debugging enabled (automatic on all sandboxes)
|
|
159
|
+
- A valid 2captcha API key with sufficient balance
|