testdriverai 7.2.56 → 7.2.58

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.
@@ -2,168 +2,169 @@ name: TestDriver.ai Tests
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [ main, master ]
5
+ branches: [main, master]
6
6
  pull_request:
7
- branches: [ main, master ]
7
+ branches: [main, master]
8
8
 
9
9
  jobs:
10
10
  test:
11
11
  runs-on: ubuntu-latest
12
-
12
+
13
13
  permissions:
14
14
  contents: read
15
- pull-requests: write # Required to post comments on PRs
15
+ pull-requests: write # Required to post comments on PRs
16
16
 
17
17
  steps:
18
- - uses: actions/checkout@v4
19
-
20
- - name: Setup Node.js
21
- uses: actions/setup-node@v4
22
- with:
23
- node-version: '20'
24
- cache: 'npm'
25
-
26
- - name: Install dependencies
27
- run: npm ci
28
-
29
- - name: Run TestDriver.ai tests
30
- env:
31
- TD_API_KEY: ${{ secrets.TD_API_KEY }}
32
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33
- GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
34
- run: npx vitest run
35
-
36
- - name: Upload test results
37
- if: always()
38
- uses: actions/upload-artifact@v4
39
- with:
40
- name: test-results
41
- path: test-results/
42
- retention-days: 30
43
-
44
- # Init command test - only runs on PRs, not on main/master
45
- - name: Create test directory for init
46
- if: github.event_name == 'pull_request'
47
- run: |
48
- mkdir -p /tmp/test-init-project
49
- cd /tmp/test-init-project
50
-
51
- - name: Run init command (skip prompts)
52
- if: github.event_name == 'pull_request'
53
- working-directory: /tmp/test-init-project
54
- run: |
55
- # Create .env with API key first to skip the prompt
56
- echo "TD_API_KEY=${{ secrets.TD_API_KEY }}" > .env
57
-
58
- # Run init command using the CLI from the repo
59
- node ${{ github.workspace }}/bin/testdriverai.js init
60
- env:
61
- TD_API_KEY: ${{ secrets.TD_API_KEY }}
62
-
63
- - name: Verify project structure
64
- if: github.event_name == 'pull_request'
65
- working-directory: /tmp/test-init-project
66
- run: |
67
- echo "Checking generated files..."
68
-
69
- # Check for package.json
70
- if [ ! -f "package.json" ]; then
71
- echo "package.json not found"
72
- exit 1
73
- fi
74
- echo "✓ package.json exists"
75
-
76
- # Check for vitest config
77
- if [ ! -f "vitest.config.js" ]; then
78
- echo "vitest.config.js not found"
79
- exit 1
80
- fi
81
- echo "✓ vitest.config.js exists"
82
-
83
- # Check for test file
84
- if [ ! -f "tests/example.test.js" ]; then
85
- echo "tests/example.test.js not found"
86
- exit 1
87
- fi
88
- echo "✓ tests/example.test.js exists"
89
-
90
- # Check for .env file
91
- if [ ! -f ".env" ]; then
92
- echo ".env not found"
93
- exit 1
94
- fi
95
- echo "✓ .env exists"
96
-
97
- # Check for .gitignore
98
- if [ ! -f ".gitignore" ]; then
99
- echo ".gitignore not found"
100
- exit 1
101
- fi
102
- echo "✓ .gitignore exists"
103
-
104
- # Check for GitHub workflow
105
- if [ ! -f ".github/workflows/testdriver.yml" ]; then
106
- echo ".github/workflows/testdriver.yml not found"
107
- exit 1
108
- fi
109
- echo "✓ .github/workflows/testdriver.yml exists"
110
-
111
- - name: Verify vitest config contents
112
- if: github.event_name == 'pull_request'
113
- working-directory: /tmp/test-init-project
114
- run: |
115
- echo "Checking vitest.config.js contents..."
116
-
117
- # Check for TestDriver reporter
118
- if ! grep -q "TestDriver()" vitest.config.js; then
119
- echo "❌ TestDriver reporter not found in vitest.config.js"
120
- cat vitest.config.js
121
- exit 1
122
- fi
123
- echo "✓ TestDriver reporter is configured"
124
-
125
- # Check for setupFiles
126
- if ! grep -q "setupFiles.*testdriverai/vitest/setup" vitest.config.js; then
127
- echo "setupFiles not configured correctly"
128
- cat vitest.config.js
129
- exit 1
130
- fi
131
- echo "✓ setupFiles is configured"
132
-
133
- - name: Verify test file contents
134
- if: github.event_name == 'pull_request'
135
- working-directory: /tmp/test-init-project
136
- run: |
137
- echo "Checking test file contents..."
138
-
139
- # Check for .provision usage
140
- if ! grep -q "\.provision\.chrome" tests/example.test.js; then
141
- echo "❌ Test does not use .provision.chrome"
142
- cat tests/example.test.js
143
- exit 1
144
- fi
145
- echo "✓ Test uses .provision.chrome"
146
-
147
- # Check for TestDriver import
148
- if ! grep -q "from 'testdriverai/vitest/hooks'" tests/example.test.js; then
149
- echo "❌ Test does not import from testdriverai/vitest/hooks"
150
- cat tests/example.test.js
151
- exit 1
152
- fi
153
- echo "✓ Test imports TestDriver from vitest/hooks"
154
-
155
- - name: Run the generated test
156
- if: github.event_name == 'pull_request'
157
- working-directory: /tmp/test-init-project
158
- run: npm test
159
- env:
160
- TD_API_KEY: ${{ secrets.TD_API_KEY }}
161
-
162
- - name: Upload init test results
163
- if: always() && github.event_name == 'pull_request'
164
- uses: actions/upload-artifact@v4
165
- with:
166
- name: test-init-results
167
- path: /tmp/test-init-project/test-results/
168
- retention-days: 7
169
- if-no-files-found: warn
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Setup Node.js
21
+ uses: actions/setup-node@v4
22
+ with:
23
+ node-version: "20"
24
+ cache: "npm"
25
+
26
+ - name: Install dependencies
27
+ run: npm ci
28
+
29
+ - name: Run TestDriver.ai tests
30
+ env:
31
+ TD_API_KEY: ${{ secrets.TD_API_KEY }}
32
+ TWOCAPTCHA_API_KEY: ${{ secrets.TWOCAPTCHA_API_KEY }}
33
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34
+ GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
35
+ run: npx vitest run
36
+
37
+ - name: Upload test results
38
+ if: always()
39
+ uses: actions/upload-artifact@v4
40
+ with:
41
+ name: test-results
42
+ path: test-results/
43
+ retention-days: 30
44
+
45
+ # Init command test - only runs on PRs, not on main/master
46
+ - name: Create test directory for init
47
+ if: github.event_name == 'pull_request'
48
+ run: |
49
+ mkdir -p /tmp/test-init-project
50
+ cd /tmp/test-init-project
51
+
52
+ - name: Run init command (skip prompts)
53
+ if: github.event_name == 'pull_request'
54
+ working-directory: /tmp/test-init-project
55
+ run: |
56
+ # Create .env with API key first to skip the prompt
57
+ echo "TD_API_KEY=${{ secrets.TD_API_KEY }}" > .env
58
+
59
+ # Run init command using the CLI from the repo
60
+ node ${{ github.workspace }}/bin/testdriverai.js init
61
+ env:
62
+ TD_API_KEY: ${{ secrets.TD_API_KEY }}
63
+
64
+ - name: Verify project structure
65
+ if: github.event_name == 'pull_request'
66
+ working-directory: /tmp/test-init-project
67
+ run: |
68
+ echo "Checking generated files..."
69
+
70
+ # Check for package.json
71
+ if [ ! -f "package.json" ]; then
72
+ echo "❌ package.json not found"
73
+ exit 1
74
+ fi
75
+ echo "✓ package.json exists"
76
+
77
+ # Check for vitest config
78
+ if [ ! -f "vitest.config.js" ]; then
79
+ echo "❌ vitest.config.js not found"
80
+ exit 1
81
+ fi
82
+ echo "✓ vitest.config.js exists"
83
+
84
+ # Check for test file
85
+ if [ ! -f "tests/example.test.js" ]; then
86
+ echo "❌ tests/example.test.js not found"
87
+ exit 1
88
+ fi
89
+ echo "✓ tests/example.test.js exists"
90
+
91
+ # Check for .env file
92
+ if [ ! -f ".env" ]; then
93
+ echo "❌ .env not found"
94
+ exit 1
95
+ fi
96
+ echo "✓ .env exists"
97
+
98
+ # Check for .gitignore
99
+ if [ ! -f ".gitignore" ]; then
100
+ echo "❌ .gitignore not found"
101
+ exit 1
102
+ fi
103
+ echo "✓ .gitignore exists"
104
+
105
+ # Check for GitHub workflow
106
+ if [ ! -f ".github/workflows/testdriver.yml" ]; then
107
+ echo "❌ .github/workflows/testdriver.yml not found"
108
+ exit 1
109
+ fi
110
+ echo "✓ .github/workflows/testdriver.yml exists"
111
+
112
+ - name: Verify vitest config contents
113
+ if: github.event_name == 'pull_request'
114
+ working-directory: /tmp/test-init-project
115
+ run: |
116
+ echo "Checking vitest.config.js contents..."
117
+
118
+ # Check for TestDriver reporter
119
+ if ! grep -q "TestDriver()" vitest.config.js; then
120
+ echo "❌ TestDriver reporter not found in vitest.config.js"
121
+ cat vitest.config.js
122
+ exit 1
123
+ fi
124
+ echo "✓ TestDriver reporter is configured"
125
+
126
+ # Check for setupFiles
127
+ if ! grep -q "setupFiles.*testdriverai/vitest/setup" vitest.config.js; then
128
+ echo "❌ setupFiles not configured correctly"
129
+ cat vitest.config.js
130
+ exit 1
131
+ fi
132
+ echo "✓ setupFiles is configured"
133
+
134
+ - name: Verify test file contents
135
+ if: github.event_name == 'pull_request'
136
+ working-directory: /tmp/test-init-project
137
+ run: |
138
+ echo "Checking test file contents..."
139
+
140
+ # Check for .provision usage
141
+ if ! grep -q "\.provision\.chrome" tests/example.test.js; then
142
+ echo "❌ Test does not use .provision.chrome"
143
+ cat tests/example.test.js
144
+ exit 1
145
+ fi
146
+ echo "✓ Test uses .provision.chrome"
147
+
148
+ # Check for TestDriver import
149
+ if ! grep -q "from 'testdriverai/vitest/hooks'" tests/example.test.js; then
150
+ echo "❌ Test does not import from testdriverai/vitest/hooks"
151
+ cat tests/example.test.js
152
+ exit 1
153
+ fi
154
+ echo "✓ Test imports TestDriver from vitest/hooks"
155
+
156
+ - name: Run the generated test
157
+ if: github.event_name == 'pull_request'
158
+ working-directory: /tmp/test-init-project
159
+ run: npm test
160
+ env:
161
+ TD_API_KEY: ${{ secrets.TD_API_KEY }}
162
+
163
+ - name: Upload init test results
164
+ if: always() && github.event_name == 'pull_request'
165
+ uses: actions/upload-artifact@v4
166
+ with:
167
+ name: test-init-results
168
+ path: /tmp/test-init-project/test-results/
169
+ retention-days: 7
170
+ if-no-files-found: warn
@@ -4,13 +4,15 @@ on:
4
4
  workflow_call:
5
5
  inputs:
6
6
  test_pattern:
7
- description: 'Test file pattern to run'
7
+ description: "Test file pattern to run"
8
8
  required: false
9
9
  type: string
10
- default: 'examples/*.test.mjs'
10
+ default: "examples/*.test.mjs"
11
11
  secrets:
12
12
  TD_API_KEY:
13
13
  required: true
14
+ TWOCAPTCHA_API_KEY:
15
+ required: true
14
16
  TD_WEBSITE:
15
17
  required: false
16
18
  AWS_ACCESS_KEY_ID:
@@ -21,48 +23,60 @@ on:
21
23
  jobs:
22
24
  test:
23
25
  runs-on: ubuntu-latest
24
-
26
+
25
27
  steps:
26
- - name: Checkout repository
27
- uses: actions/checkout@v4
28
- with:
29
- fetch-depth: 0
30
-
31
- - name: Set up Node.js
32
- uses: actions/setup-node@v4
33
- with:
34
- node-version: '20'
35
- cache: 'npm'
36
-
37
- - name: Install dependencies
38
- run: npm ci
39
-
40
- - name: Run Windows tests with self-hosted instances
41
- run: npx vitest run ${{ inputs.test_pattern }}
42
- env:
43
- TD_API_KEY: ${{ secrets.TD_API_KEY }}
44
- TD_WEBSITE: ${{ secrets.TD_WEBSITE }}
45
- TD_OS: windows
46
- AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
47
- AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
48
- AWS_REGION: us-east-2
49
- AWS_LAUNCH_TEMPLATE_ID: lt-0ef9bf26a945fb442
50
- AMI_ID: ami-0dd5fa241273a7d50
51
- RESOLUTION: 1920x1080
52
-
53
- - name: Upload test results
54
- if: always()
55
- uses: actions/upload-artifact@v4
56
- with:
57
- name: test-results-windows
58
- path: test-report.junit.xml
59
- retention-days: 30
60
-
61
- - name: Upload TestDriver AI CLI logs
62
- if: always()
63
- uses: actions/upload-artifact@v4
64
- with:
65
- name: testdriverai-cli-logs-windows
66
- path: /tmp/testdriverai-cli-*.log
67
- if-no-files-found: warn
68
- retention-days: 30
28
+ - name: Checkout repository
29
+ uses: actions/checkout@v4
30
+ with:
31
+ fetch-depth: 0
32
+
33
+ - name: Set up Node.js
34
+ uses: actions/setup-node@v4
35
+ with:
36
+ node-version: "20"
37
+ cache: "npm"
38
+
39
+ - name: Install dependencies
40
+ run: npm ci
41
+
42
+ - name: Debug Environment
43
+ run: |
44
+ echo "Checking environment variables..."
45
+ if [ -n "${{ secrets.TWOCAPTCHA_API_KEY }}" ]; then
46
+ echo "TWOCAPTCHA_API_KEY is set (length: ${#TWOCAPTCHA_API_KEY})"
47
+ else
48
+ echo "TWOCAPTCHA_API_KEY is NOT set"
49
+ fi
50
+ env:
51
+ TWOCAPTCHA_API_KEY: ${{ secrets.TWOCAPTCHA_API_KEY }}
52
+
53
+ - name: Run Windows tests with self-hosted instances
54
+ run: npx vitest run ${{ inputs.test_pattern }}
55
+ env:
56
+ TD_API_KEY: ${{ secrets.TD_API_KEY }}
57
+ TWOCAPTCHA_API_KEY: ${{ secrets.TWOCAPTCHA_API_KEY }}
58
+ TD_WEBSITE: ${{ secrets.TD_WEBSITE }}
59
+ TD_OS: windows
60
+ AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
61
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
62
+ AWS_REGION: us-east-2
63
+ AWS_LAUNCH_TEMPLATE_ID: lt-0ef9bf26a945fb442
64
+ AMI_ID: ami-0dd5fa241273a7d50
65
+ RESOLUTION: 1920x1080
66
+
67
+ - name: Upload test results
68
+ if: always()
69
+ uses: actions/upload-artifact@v4
70
+ with:
71
+ name: test-results-windows
72
+ path: test-report.junit.xml
73
+ retention-days: 30
74
+
75
+ - name: Upload TestDriver AI CLI logs
76
+ if: always()
77
+ uses: actions/upload-artifact@v4
78
+ with:
79
+ name: testdriverai-cli-logs-windows
80
+ path: /tmp/testdriverai-cli-*.log
81
+ if-no-files-found: warn
82
+ retention-days: 30
package/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ ## [7.2.58](https://github.com/testdriverai/testdriverai/compare/v6.1.8...v7.2.58) (2026-01-27)
2
+
3
+
4
+ ### Reverts
5
+
6
+ * Revert "list dashcam version g" ([5037571](https://github.com/testdriverai/testdriverai/commit/5037571440c33f8966104874c542c6c57a809510))
7
+ * Revert "update discord invite" ([b5a9b99](https://github.com/testdriverai/testdriverai/commit/b5a9b9955cf2b0b07fd0ebeb6abf65f89cd3d5a8))
8
+
9
+
10
+
package/docs/docs.json CHANGED
@@ -72,6 +72,7 @@
72
72
  "pages": [
73
73
  "/v7/ai",
74
74
  "/v7/assert",
75
+ "/v7/captcha",
75
76
  "/v7/click",
76
77
  "/v7/double-click",
77
78
  "/v7/exec",
@@ -0,0 +1,160 @@
1
+ ---
2
+ title: "captcha()"
3
+ sidebarTitle: "captcha"
4
+ description: "Solve captchas using 2captcha service"
5
+ icon: "shield-check"
6
+ ---
7
+
8
+ # Captcha Solving
9
+
10
+ TestDriver can automatically solve captchas during your tests using the 2captcha service. This feature works on both **Linux** and **Windows** sandboxes.
11
+
12
+ ## Quick Start
13
+
14
+
15
+ ```javascript
16
+ const result = await testdriver.captcha({
17
+ apiKey: process.env.TWOCAPTCHA_API_KEY,
18
+ });
19
+
20
+ console.log(result.success); // true
21
+ console.log(result.token); // The solved captcha token
22
+ ```
23
+
24
+ That's it! TestDriver will automatically:
25
+ - Detect the captcha type on the page
26
+ - Extract the sitekey
27
+ - Solve the captcha via 2captcha
28
+ - Inject the token into the page
29
+ - Trigger any callbacks
30
+
31
+ ## Supported Captcha Types
32
+
33
+ | Type | Auto-Detected | Notes |
34
+ |------|---------------|-------|
35
+ | reCAPTCHA v2 | ✅ | Including invisible |
36
+ | reCAPTCHA v3 | ✅ | Action is auto-detected |
37
+ | hCaptcha | ✅ | |
38
+ | Cloudflare Turnstile | ✅ | |
39
+
40
+ ## Getting a 2captcha API Key
41
+
42
+ 1. Sign up at [2captcha.com](https://2captcha.com)
43
+ 2. Add funds to your account
44
+ 3. Copy your API key from the dashboard
45
+
46
+ ## Configuration Options
47
+
48
+ ```javascript
49
+ const result = await testdriver.captcha({
50
+ // Required
51
+ apiKey: '2CAPTCHA_API_KEY',
52
+
53
+ // Optional - usually auto-detected
54
+ sitekey: '6Le...', // Override auto-detected sitekey
55
+ type: 'recaptcha_v3', // Override auto-detected type
56
+ action: 'submit', // reCAPTCHA v3 action
57
+
58
+ // Timing
59
+ timeout: 120000, // Max wait time (default: 120s)
60
+ pollInterval: 5000, // Poll interval (default: 5s)
61
+ });
62
+ ```
63
+
64
+ ## Full Example
65
+
66
+ ```javascript
67
+ import { describe, expect, it } from "vitest";
68
+ import { TestDriver } from "testdriver";
69
+
70
+ describe("Checkout flow", () => {
71
+ it("should complete checkout with captcha", async (context) => {
72
+ const testdriver = TestDriver(context);
73
+
74
+ // Navigate to checkout page
75
+ await testdriver.provision.chrome({
76
+ url: 'https://example.com/checkout',
77
+ });
78
+
79
+ // Fill out form
80
+ await testdriver.type({ text: 'John Doe', selector: '#name' });
81
+ await testdriver.type({ text: 'john@example.com', selector: '#email' });
82
+
83
+ // Solve the captcha
84
+ const result = await testdriver.captcha({
85
+ apiKey: process.env.TWOCAPTCHA_API_KEY,
86
+ });
87
+
88
+ expect(result.success).toBe(true);
89
+
90
+ // Submit the form
91
+ await testdriver.click({ selector: '#submit' });
92
+
93
+ // Verify success
94
+ await testdriver.find({ text: 'Order confirmed' });
95
+ }, 180000);
96
+ });
97
+ ```
98
+
99
+ ## Environment Variables
100
+
101
+ You can set your API key as an environment variable:
102
+
103
+ ```bash
104
+ export TWOCAPTCHA_API_KEY=your_api_key_here
105
+ ```
106
+
107
+ Then use it in your tests:
108
+
109
+ ```javascript
110
+ ```javascript
111
+ const result = await testdriver.captcha({
112
+ apiKey: process.env.TWOCAPTCHA_API_KEY,
113
+ });
114
+ ```
115
+
116
+ ### GitHub Actions
117
+
118
+ Add the key to your repository secrets and expose it in your workflow:
119
+
120
+ ```yaml
121
+ - name: Run Tests
122
+ run: npm test
123
+ env:
124
+ TWOCAPTCHA_API_KEY: ${{ secrets.TWOCAPTCHA_API_KEY }}
125
+ ```
126
+
127
+ ## How It Works
128
+
129
+ 1. **Detection**: Scans the page for captcha elements (`data-sitekey`, script tags, etc.)
130
+ 2. **Submit**: Sends the captcha challenge to 2captcha's solving service
131
+ 3. **Poll**: Waits for human solvers to complete the captcha
132
+ 4. **Inject**: Injects the solved token into the page's hidden fields
133
+ 5. **Callback**: Triggers any JavaScript callbacks the page expects
134
+
135
+ ## Troubleshooting
136
+
137
+ ### "Could not auto-detect captcha"
138
+
139
+ The captcha element wasn't found on the page. Try:
140
+ - Waiting for the page to fully load before calling `captcha()`
141
+ - Providing the `sitekey` and `type` manually
142
+
143
+ ### Timeout errors
144
+
145
+ Captcha solving typically takes 10-30 seconds. If you're getting timeouts:
146
+ - Increase the `timeout` option
147
+ - Check your 2captcha balance
148
+ - Verify the captcha type is correct
149
+
150
+ ### Token not working
151
+
152
+ Some sites validate tokens immediately. Make sure:
153
+ - The token is injected before form submission
154
+ - The captcha type matches what the site expects
155
+ - For reCAPTCHA v3, the `action` parameter matches the site's expected action
156
+
157
+ ## Requirements
158
+
159
+ - Chrome must be launched with remote debugging enabled (automatic on all sandboxes)
160
+ - A valid 2captcha API key with sufficient balance