testdriverai 4.0.50 → 4.0.52
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/index.js +20 -0
- package/lib/commands.js +3 -1
- package/lib/focus-application.js +3 -0
- package/lib/redraw.js +18 -26
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const package = require("./package.json");
|
|
|
10
10
|
const fs = require("fs");
|
|
11
11
|
const readline = require("readline");
|
|
12
12
|
const os = require("os");
|
|
13
|
+
const http = require('http');
|
|
13
14
|
|
|
14
15
|
// third party modules
|
|
15
16
|
const path = require("path");
|
|
@@ -668,6 +669,25 @@ New commands will be appended.
|
|
|
668
669
|
|
|
669
670
|
let setTerminalWindowTransparency = async (hide) => {
|
|
670
671
|
|
|
672
|
+
if (hide) {
|
|
673
|
+
|
|
674
|
+
try {
|
|
675
|
+
http.get('http://localhost:60305/hide').on('error',function(){}).end();
|
|
676
|
+
} catch (e) {
|
|
677
|
+
// Suppress error
|
|
678
|
+
console.error('Caught exception:', e);
|
|
679
|
+
}
|
|
680
|
+
} else {
|
|
681
|
+
|
|
682
|
+
try {
|
|
683
|
+
http.get('http://localhost:60305/hide').on('error',function(){}).end();
|
|
684
|
+
} catch (e) {
|
|
685
|
+
// Suppress error
|
|
686
|
+
console.error('Caught exception:', e);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
}
|
|
690
|
+
|
|
671
691
|
if (!config.TD_MINIMIZE) {
|
|
672
692
|
return
|
|
673
693
|
};
|
package/lib/commands.js
CHANGED
|
@@ -122,8 +122,10 @@ const assert = async (assertion, shouldThrow = false, async = false) => {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
const handleAssertResponse = (response) => {
|
|
125
|
+
|
|
126
|
+
logger.prettyMarkdown(response);
|
|
127
|
+
|
|
125
128
|
if (response.indexOf("The task passed") > -1) {
|
|
126
|
-
logger.prettyMarkdown(response);
|
|
127
129
|
return true;
|
|
128
130
|
} else {
|
|
129
131
|
if (shouldThrow) {
|
package/lib/focus-application.js
CHANGED
|
@@ -40,6 +40,7 @@ async function focusApplication(appName) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
async function hideTerminal(appName) {
|
|
43
|
+
|
|
43
44
|
try {
|
|
44
45
|
if (platform() == "mac") {
|
|
45
46
|
return await execSync(`osascript -e '${appleScriptMin(appName)}'`);
|
|
@@ -52,6 +53,7 @@ async function hideTerminal(appName) {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
async function showTerminal(appName) {
|
|
56
|
+
|
|
55
57
|
try {
|
|
56
58
|
if (platform() == "mac") {
|
|
57
59
|
return await execSync(`osascript -e '${appleScriptMax(appName)}'`);
|
|
@@ -68,3 +70,4 @@ module.exports = {
|
|
|
68
70
|
hideTerminal,
|
|
69
71
|
showTerminal,
|
|
70
72
|
};
|
|
73
|
+
|
package/lib/redraw.js
CHANGED
|
@@ -25,34 +25,26 @@ async function start() {
|
|
|
25
25
|
|
|
26
26
|
function wait(timeoutMs) {
|
|
27
27
|
|
|
28
|
-
// wait for a certain amount of time
|
|
29
28
|
return new Promise((resolve) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
}, 0);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
checkCondition();
|
|
33
47
|
});
|
|
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
|
-
// });
|
|
56
48
|
}
|
|
57
49
|
|
|
58
50
|
module.exports = { start, wait };
|