testdriverai 4.0.48 → 4.0.49
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/lib/redraw.js +27 -16
- package/package.json +1 -1
package/lib/redraw.js
CHANGED
|
@@ -24,24 +24,35 @@ async function start() {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function wait(timeoutMs) {
|
|
27
|
+
|
|
28
|
+
// wait for a certain amount of time
|
|
27
29
|
return new Promise((resolve) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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(checkCondition, 0);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
checkCondition();
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
resolve("Timeout reached");
|
|
32
|
+
}, timeoutMs);
|
|
44
33
|
});
|
|
34
|
+
|
|
35
|
+
// return new Promise((resolve) => {
|
|
36
|
+
// const startTime = Date.now();
|
|
37
|
+
|
|
38
|
+
// async function checkCondition() {
|
|
39
|
+
// console.log('check condition')
|
|
40
|
+
// let nowImage = await captureScreenPNG();
|
|
41
|
+
// let result = await compareImages(startImage, nowImage);
|
|
42
|
+
|
|
43
|
+
// if (result) {
|
|
44
|
+
// resolve("Condition met");
|
|
45
|
+
// } else if (Date.now() - startTime >= timeoutMs) {
|
|
46
|
+
// resolve("Timeout reached");
|
|
47
|
+
// } else {
|
|
48
|
+
// setTimeout(() => {
|
|
49
|
+
// checkCondition();
|
|
50
|
+
// }, 0);
|
|
51
|
+
// }
|
|
52
|
+
// }
|
|
53
|
+
|
|
54
|
+
// checkCondition();
|
|
55
|
+
// });
|
|
45
56
|
}
|
|
46
57
|
|
|
47
58
|
module.exports = { start, wait };
|