testdriverai 4.0.30 → 4.0.32

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/analytics.js CHANGED
@@ -1,11 +1,14 @@
1
1
  const sdk = require('./sdk');
2
+ const config = require('./config');
2
3
 
3
- module.exports = {track: async (event, data) => {
4
+ module.exports = {
5
+ track: async (event, data) => {
4
6
 
5
- if (process.env["TD_ANALYTICS"]) {
6
- return;
7
- } else {
8
- sdk.req('analytics', {event, data});
9
- }
7
+ if (config["TD_ANALYTICS"]) {
8
+ return;
9
+ } else {
10
+ sdk.req('analytics', { event, data });
11
+ }
10
12
 
11
- }};
13
+ }
14
+ };
package/lib/commands.js CHANGED
@@ -40,23 +40,28 @@ const findImageOnScreen = async (relativePath, haystack, restrictToWindow) => {
40
40
  relativePath = relativePath + '.png';
41
41
  }
42
42
 
43
+ let needle = path.join(rootpath, relativePath);
44
+
43
45
  // check if the file exists
44
- if (await !fs.access(path.join(rootpath, relativePath))) {
45
- throw new AiError(`Image not found: ${relativePath}`)
46
+ if (await !fs.access(needle)) {
47
+ throw new AiError(`Image does not exist or do not have access: ${needle}`)
46
48
  }
47
49
 
48
- let needle = path.join(rootpath, relativePath);
49
-
50
50
  const bar1 = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);
51
51
 
52
52
  let thresholds = [
53
- 0.9
53
+ 0.9,
54
+ 0.8,
55
+ 0.7,
54
56
  ];
55
57
 
56
58
  let scaleFactors = [
57
59
  1,
58
60
  .5,
59
- 2
61
+ 2,
62
+ .75,
63
+ 1.25,
64
+ 1.5
60
65
  ];
61
66
 
62
67
  let result = null;
@@ -222,6 +227,9 @@ const hover = async(x, y) => {
222
227
  }
223
228
 
224
229
  let commands = {
230
+ scroll: scroll,
231
+ click: click,
232
+ hover: hover,
225
233
  // method, levenshein, dice, or combined
226
234
  // leven = this is turbo, all around good for text similarity
227
235
  // dice = this is good for short strings, but not as good for long strings
@@ -441,7 +449,6 @@ let commands = {
441
449
  }
442
450
 
443
451
  },
444
- scroll,
445
452
  "scroll-until-text": async(text, direction = 'down', maxDistance = 1200, method = 'ai') => {
446
453
 
447
454
  await redraw.start();
package/lib/config.js ADDED
@@ -0,0 +1,30 @@
1
+ require('dotenv').config()
2
+
3
+ // Parse out true and false string values
4
+ function parseValue(value) {
5
+ if (value === "false") {
6
+ return false;
7
+ }
8
+
9
+ if (value === "true") {
10
+ return true;
11
+ }
12
+
13
+ return value;
14
+ }
15
+
16
+ // Object for TD related config, with defaults
17
+ const config = {
18
+ TD_SPEAK: false,
19
+ TD_ANALYTICS: false,
20
+ TD_NOTIFY: false,
21
+ };
22
+
23
+ // Find all env vars starting with TD_
24
+ for (let key in process.env) {
25
+ if (key.startsWith("TD_")) {
26
+ config[key] = parseValue(process.env[key]);
27
+ }
28
+ }
29
+
30
+ module.exports = config;
package/lib/notify.js CHANGED
@@ -1,9 +1,10 @@
1
1
  const notifier = require("node-notifier");
2
2
  const path = require("path");
3
+ const config = require("./config");
3
4
 
4
5
  module.exports = (message) => {
5
6
 
6
- if (process.env["TD_NOTIFY"]) {
7
+ if (config["TD_NOTIFY"]) {
7
8
 
8
9
  return notifier.notify({
9
10
  title: "TestDriver.ai",
package/lib/speak.js CHANGED
@@ -1,8 +1,9 @@
1
1
  const say = require('say');
2
+ const config = require('./config');
2
3
 
3
4
  module.exports = (message) => {
4
5
 
5
- if (process.env["TD_SPEAK"]) {
6
+ if (config["TD_SPEAK"]) {
6
7
  say.stop();
7
8
  if (process.platform === 'darwin') {
8
9
  say.speak(message, 'Fred', 1.2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "4.0.30",
3
+ "version": "4.0.32",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {