testdriverai 4.1.20 → 4.1.21

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 (3) hide show
  1. package/agent.js +1 -1
  2. package/lib/system.js +15 -12
  3. package/package.json +1 -1
package/agent.js CHANGED
@@ -295,7 +295,7 @@ const check = async () => {
295
295
  log.log("info", chalk.dim("checking..."), "testdriver");
296
296
  log.log("info", "");
297
297
 
298
- let thisScreenshot = await system.captureScreenBase64();
298
+ let thisScreenshot = await system.captureScreenBase64(1, false, true);
299
299
  let images = [lastScreenshot, thisScreenshot];
300
300
  let mousePosition = await system.getMousePosition();
301
301
  let activeWindow = await system.activeWin();
package/lib/system.js CHANGED
@@ -32,7 +32,7 @@ const tmpFilename = () => {
32
32
  return path.join(os.tmpdir(), `${new Date().getTime() + Math.random()}.png`);
33
33
  };
34
34
 
35
- const captureAndResize = async (scale = 1, silent = false) => {
35
+ const captureAndResize = async (scale = 1, silent = false, mouse = false) => {
36
36
  try {
37
37
  const primaryDisplay = await getPrimaryDisplay();
38
38
  if (!silent) {
@@ -55,14 +55,17 @@ const captureAndResize = async (scale = 1, silent = false) => {
55
55
  const cursorPath = path.join(__dirname, "resources", "cursor.png");
56
56
 
57
57
  // resize to 1:1 px ratio
58
- await sharp(step1)
59
- .resize(
60
- Math.floor(primaryDisplay.currentResX * scale),
61
- Math.floor(primaryDisplay.currentResY * scale),
62
- )
58
+ const sharpInstance = sharp(step1).resize(
59
+ Math.floor(primaryDisplay.currentResX * scale),
60
+ Math.floor(primaryDisplay.currentResY * scale),
61
+ );
62
+
63
+ if (mouse) {
63
64
  // composite the mouse image ontop
64
- .composite([{ input: cursorPath, left: mousePos.x, top: mousePos.y }])
65
- .toFile(step2);
65
+ sharpInstance.composite([{ input: cursorPath, left: mousePos.x, top: mousePos.y }]);
66
+ }
67
+
68
+ await sharpInstance.toFile(step2);
66
69
 
67
70
  emitter.emit(events.screenCapture.end, {
68
71
  scale,
@@ -83,13 +86,13 @@ const captureAndResize = async (scale = 1, silent = false) => {
83
86
  };
84
87
 
85
88
  // our handy screenshot function
86
- const captureScreenBase64 = async (scale = 1, silent = false) => {
87
- let step2 = await captureAndResize(scale, silent);
89
+ const captureScreenBase64 = async (scale = 1, silent = false, mouse = false) => {
90
+ let step2 = await captureAndResize(scale, silent, mouse);
88
91
  return fs.readFileSync(step2, "base64");
89
92
  };
90
93
 
91
- const captureScreenPNG = async (scale = 1, silent = false) => {
92
- return await captureAndResize(scale, silent);
94
+ const captureScreenPNG = async (scale = 1, silent = false, mouse = false) => {
95
+ return await captureAndResize(scale, silent, mouse);
93
96
  };
94
97
 
95
98
  const platform = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "4.1.20",
3
+ "version": "4.1.21",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {