testdriverai 4.0.64 → 4.0.66

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/index.js +17 -1
  2. package/lib/redraw.js +30 -31
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -1,4 +1,21 @@
1
1
  #!/usr/bin/env node
2
+ const os = require('os');
3
+
4
+ // Get the current process ID
5
+ const pid = process.pid;
6
+
7
+ try {
8
+ // Display the current priority
9
+ console.log('Current priority:', os.getPriority(pid));
10
+
11
+ // Set the priority to the highest value
12
+ os.setPriority(pid, -20);
13
+
14
+ // Display the updated priority
15
+ console.log('Updated priority:', os.getPriority(pid));
16
+ } catch (error) {
17
+ console.error('Failed to set process priority:', error);
18
+ }
2
19
 
3
20
  // disable depreciation warnings
4
21
  process.removeAllListeners("warning");
@@ -11,7 +28,6 @@ require("./lib/profiler");
11
28
 
12
29
  const fs = require("fs");
13
30
  const readline = require("readline");
14
- const os = require("os");
15
31
  const http = require('http');
16
32
 
17
33
  // third party modules
package/lib/redraw.js CHANGED
@@ -1,20 +1,20 @@
1
1
  const { captureScreenPNG } = require("./system");
2
2
 
3
- // const Jimp = require("jimp");
3
+ const Jimp = require("jimp");
4
4
 
5
- // async function compareImages(image1Url, image2Url) {
6
- // const image1 = await Jimp.read(image1Url);
7
- // const image2 = await Jimp.read(image2Url);
5
+ async function compareImages(image1Url, image2Url) {
6
+ const image1 = await Jimp.read(image1Url);
7
+ const image2 = await Jimp.read(image2Url);
8
8
 
9
- // // Pixel difference
10
- // const diff = Jimp.diff(image1, image2);
9
+ // Pixel difference
10
+ const diff = Jimp.diff(image1, image2);
11
11
 
12
- // if (diff.percent < 0.15) {
13
- // return false;
14
- // } else {
15
- // return true;
16
- // }
17
- // }
12
+ if (diff.percent < 0.15) {
13
+ return false;
14
+ } else {
15
+ return true;
16
+ }
17
+ }
18
18
 
19
19
  let startImage = null;
20
20
 
@@ -25,25 +25,24 @@ async function start() {
25
25
 
26
26
  function wait(timeoutMs) {
27
27
  return new Promise((resolve) => {
28
- setTimeout(resolve, timeoutMs);
29
- // const startTime = Date.now();
30
-
31
- // async function checkCondition() {
32
- // let nowImage = await captureScreenPNG();
33
- // let result = await compareImages(startImage, nowImage);
34
-
35
- // if (result) {
36
- // resolve("Condition met");
37
- // } else if (Date.now() - startTime >= timeoutMs) {
38
- // resolve("Timeout reached");
39
- // } else {
40
- // setTimeout(() => {
41
- // checkCondition();
42
- // }, 200);
43
- // }
44
- // }
45
-
46
- // checkCondition();
28
+ const startTime = Date.now();
29
+
30
+ async function checkCondition() {
31
+ let nowImage = await captureScreenPNG();
32
+ let result = await compareImages(startImage, nowImage);
33
+
34
+ if (result) {
35
+ resolve("Condition met");
36
+ } else if (Date.now() - startTime >= timeoutMs) {
37
+ resolve("Timeout reached");
38
+ } else {
39
+ setTimeout(() => {
40
+ checkCondition();
41
+ }, 200);
42
+ }
43
+ }
44
+
45
+ checkCondition();
47
46
  });
48
47
  }
49
48
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "4.0.64",
3
+ "version": "4.0.66",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {