testdriverai 7.2.52 → 7.2.54
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/agent/lib/system.js
CHANGED
|
@@ -13,12 +13,18 @@ const createSystem = (emitter, sandbox, config) => {
|
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
if (!base64) {
|
|
16
|
-
|
|
17
|
-
} else {
|
|
18
|
-
let image = Buffer.from(base64, "base64");
|
|
19
|
-
fs.writeFileSync(options.filename, image);
|
|
20
|
-
return { filename: options.filename };
|
|
16
|
+
throw new Error("Failed to take screenshot: sandbox returned empty data");
|
|
21
17
|
}
|
|
18
|
+
|
|
19
|
+
let image = Buffer.from(base64, "base64");
|
|
20
|
+
|
|
21
|
+
// Verify we got actual image data (PNG header starts with these bytes)
|
|
22
|
+
if (image.length < 100) {
|
|
23
|
+
throw new Error(`Failed to take screenshot: received only ${image.length} bytes`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
fs.writeFileSync(options.filename, image);
|
|
27
|
+
return { filename: options.filename };
|
|
22
28
|
};
|
|
23
29
|
|
|
24
30
|
let primaryDisplay = null;
|
|
@@ -57,6 +63,11 @@ const createSystem = (emitter, sandbox, config) => {
|
|
|
57
63
|
|
|
58
64
|
// Load the screenshot image with Jimp
|
|
59
65
|
let image = await Jimp.read(step1);
|
|
66
|
+
|
|
67
|
+
// Validate the image was loaded correctly (not a 1x1 or tiny placeholder)
|
|
68
|
+
if (image.getWidth() < 10 || image.getHeight() < 10) {
|
|
69
|
+
throw new Error(`Screenshot appears corrupted: got ${image.getWidth()}x${image.getHeight()} pixels`);
|
|
70
|
+
}
|
|
60
71
|
|
|
61
72
|
// Resize the image
|
|
62
73
|
image.resize(
|
package/agents.md
CHANGED
|
@@ -151,7 +151,7 @@ element.found(); // check if found (boolean)
|
|
|
151
151
|
**Use `screenshot()` liberally during development** to see exactly what the sandbox screen looks like. Screenshots are saved locally and organized by test file.
|
|
152
152
|
|
|
153
153
|
```javascript
|
|
154
|
-
// Capture a screenshot - saved to .
|
|
154
|
+
// Capture a screenshot - saved to .testdriver/screenshots/<test-file>/
|
|
155
155
|
const screenshotPath = await testdriver.screenshot();
|
|
156
156
|
console.log('Screenshot saved to:', screenshotPath);
|
|
157
157
|
|
|
@@ -168,7 +168,7 @@ await testdriver.screenshot(1, false, true);
|
|
|
168
168
|
|
|
169
169
|
**Screenshot file organization:**
|
|
170
170
|
```
|
|
171
|
-
.
|
|
171
|
+
.testdriver/
|
|
172
172
|
screenshots/
|
|
173
173
|
login.test/ # Folder per test file
|
|
174
174
|
screenshot-1737633600000.png
|
|
@@ -443,7 +443,7 @@ console.log('Screenshot with mouse saved to: screenshot-with-mouse.png');
|
|
|
443
443
|
4. **Log element properties** to understand what the AI sees
|
|
444
444
|
5. **Use `assert()` with specific, descriptive natural language**
|
|
445
445
|
6. **Start simple** - get one step working before adding more
|
|
446
|
-
7. **Take screenshots liberally** - use `await testdriver.screenshot()` after key steps to debug what the sandbox actually shows. Check `.
|
|
446
|
+
7. **Take screenshots liberally** - use `await testdriver.screenshot()` after key steps to debug what the sandbox actually shows. Check `.testdriver/screenshots/<test-file>/` to review them.
|
|
447
447
|
8. **Always `await` async methods** - TestDriver will warn if you forget, but for TypeScript projects, add `@typescript-eslint/no-floating-promises` to your ESLint config to catch missing `await` at compile time:
|
|
448
448
|
```json
|
|
449
449
|
// eslint.config.js (for TypeScript projects)
|
package/docs/v7/screenshot.mdx
CHANGED
|
@@ -35,10 +35,10 @@ const filePath = await testdriver.screenshot(scale, silent, mouse)
|
|
|
35
35
|
|
|
36
36
|
## File Organization
|
|
37
37
|
|
|
38
|
-
Screenshots are automatically saved to `.
|
|
38
|
+
Screenshots are automatically saved to `.testdriver/screenshots/<test-file-name>/` in your project root:
|
|
39
39
|
|
|
40
40
|
```
|
|
41
|
-
.
|
|
41
|
+
.testdriver/
|
|
42
42
|
screenshots/
|
|
43
43
|
login.test/
|
|
44
44
|
screenshot-1737633600000.png
|
|
@@ -136,11 +136,11 @@ describe("Login Flow", () => {
|
|
|
136
136
|
</Accordion>
|
|
137
137
|
|
|
138
138
|
<Accordion title="Add to .gitignore">
|
|
139
|
-
Add `.
|
|
139
|
+
Add `.testdriver/screenshots/` to your `.gitignore` to avoid committing screenshots to version control:
|
|
140
140
|
|
|
141
141
|
```
|
|
142
142
|
# .gitignore
|
|
143
|
-
.
|
|
143
|
+
.testdriver/screenshots/
|
|
144
144
|
```
|
|
145
145
|
</Accordion>
|
|
146
146
|
</AccordionGroup>
|
package/package.json
CHANGED
package/sdk.d.ts
CHANGED
|
@@ -1136,14 +1136,14 @@ export default class TestDriverSDK {
|
|
|
1136
1136
|
// Utility Methods
|
|
1137
1137
|
|
|
1138
1138
|
/**
|
|
1139
|
-
* Capture a screenshot of the current screen and save it to .
|
|
1139
|
+
* Capture a screenshot of the current screen and save it to .testdriver/screenshots
|
|
1140
1140
|
* @param scale - Scale factor for the screenshot (default: 1 = original size)
|
|
1141
1141
|
* @param silent - Whether to suppress logging (default: false)
|
|
1142
1142
|
* @param mouse - Whether to include mouse cursor (default: false)
|
|
1143
1143
|
* @returns The file path where the screenshot was saved
|
|
1144
1144
|
*
|
|
1145
1145
|
* @example
|
|
1146
|
-
* // Capture a screenshot (saves to .
|
|
1146
|
+
* // Capture a screenshot (saves to .testdriver/screenshots)
|
|
1147
1147
|
* const screenshotPath = await client.screenshot();
|
|
1148
1148
|
* console.log('Screenshot saved to:', screenshotPath);
|
|
1149
1149
|
*
|
package/sdk.js
CHANGED
|
@@ -2118,7 +2118,7 @@ with zipfile.ZipFile(io.BytesIO(zip_data)) as zf:
|
|
|
2118
2118
|
// Clean up screenshots folder for this test file before running
|
|
2119
2119
|
if (this.testFile) {
|
|
2120
2120
|
const testFileName = path.basename(this.testFile, path.extname(this.testFile));
|
|
2121
|
-
const screenshotsDir = path.join(process.cwd(), ".
|
|
2121
|
+
const screenshotsDir = path.join(process.cwd(), ".testdriver", "screenshots", testFileName);
|
|
2122
2122
|
if (fs.existsSync(screenshotsDir)) {
|
|
2123
2123
|
fs.rmSync(screenshotsDir, { recursive: true, force: true });
|
|
2124
2124
|
}
|
|
@@ -2791,8 +2791,8 @@ with zipfile.ZipFile(io.BytesIO(zip_data)) as zf:
|
|
|
2791
2791
|
this._ensureConnected();
|
|
2792
2792
|
const base64Data = await this.system.captureScreenBase64(scale, silent, mouse);
|
|
2793
2793
|
|
|
2794
|
-
// Save to .
|
|
2795
|
-
let screenshotsDir = path.join(process.cwd(), ".
|
|
2794
|
+
// Save to .testdriver/screenshots/<test-file-name> directory
|
|
2795
|
+
let screenshotsDir = path.join(process.cwd(), ".testdriver", "screenshots");
|
|
2796
2796
|
if (this.testFile) {
|
|
2797
2797
|
const testFileName = path.basename(this.testFile, path.extname(this.testFile));
|
|
2798
2798
|
screenshotsDir = path.join(screenshotsDir, testFileName);
|
|
Binary file
|