testdriverai 5.7.30 → 5.7.31

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 (2) hide show
  1. package/lib/commands.js +25 -31
  2. package/package.json +1 -1
package/lib/commands.js CHANGED
@@ -33,10 +33,7 @@ if (config.TD_VM) {
33
33
  keymap = require("./keymaps/robot.js");
34
34
  }
35
35
 
36
- const {
37
- logger,
38
- prettyMarkdown
39
- } = require("./logger");
36
+ const { logger, prettyMarkdown } = require("./logger");
40
37
  const { emitter, events } = require("./events.js");
41
38
 
42
39
  const niceSeconds = (ms) => {
@@ -232,7 +229,6 @@ const scroll = async (direction = "down", amount = 300, method = "mouse") => {
232
229
  // perform a mouse click
233
230
  // click, right-click, double-click, hover
234
231
  const click = async (x, y, action = "click") => {
235
-
236
232
  emitter.emit(events.interactive, true);
237
233
 
238
234
  await redraw.start();
@@ -289,10 +285,8 @@ const click = async (x, y, action = "click") => {
289
285
  } else if (action === "drag-end") {
290
286
  robot.mouseToggle("up", button);
291
287
  } else {
292
-
293
288
  robot.mouseClick(button, double);
294
289
  }
295
-
296
290
  }
297
291
 
298
292
  emitter.emit(events.mouseClick, { x, y, button, click });
@@ -357,9 +351,7 @@ let commands = {
357
351
  },
358
352
  (chunk) => {
359
353
  if (chunk.type === "data" && chunk.data) {
360
-
361
354
  // mdStream.log(chunk.data);
362
-
363
355
  } else if (chunk.type === "closeMatches") {
364
356
  emitter.emit(events.matches.show, chunk.data);
365
357
  }
@@ -421,7 +413,7 @@ let commands = {
421
413
  }
422
414
  },
423
415
  // type a string
424
- type: async (string, delay = 500) => {
416
+ type: async (string, delay = 250) => {
425
417
  await redraw.start();
426
418
 
427
419
  string = string.toString();
@@ -442,7 +434,6 @@ let commands = {
442
434
  // press keys
443
435
  // different than `type`, becasue it can press multiple keys at once
444
436
  "press-keys": async (inputKeys) => {
445
-
446
437
  await redraw.start();
447
438
 
448
439
  // robotjs is finiky with key-up on modifier keys
@@ -495,10 +486,9 @@ let commands = {
495
486
 
496
487
  modsToPress.forEach((key) => {
497
488
  robot.keyToggle(key, "down");
498
- })
489
+ });
499
490
 
500
491
  robot.keyTap(keysPressed[0], modsToPress);
501
-
502
492
  } else {
503
493
  await sandbox.send({ type: "press", keys: keysPressed });
504
494
  }
@@ -742,9 +732,9 @@ let commands = {
742
732
  return "The application was focused.";
743
733
  },
744
734
  remember: async (description) => {
745
- let result = await sdk.req("remember", {
735
+ let result = await sdk.req("remember", {
746
736
  image: await captureScreenBase64(),
747
- description
737
+ description,
748
738
  });
749
739
  return result.data;
750
740
  },
@@ -801,7 +791,10 @@ let commands = {
801
791
  chalk.dim(`running value of \`${plat}\` on this machine...`),
802
792
  true,
803
793
  );
804
- result = await exec(windows_code, { cwd: cwd(), shell: "powershell.exe" });
794
+ result = await exec(windows_code, {
795
+ cwd: cwd(),
796
+ shell: "powershell.exe",
797
+ });
805
798
  } else if (plat == "mac") {
806
799
  logger.info(
807
800
  chalk.dim(`running value of \`${plat}\` on this machine...`),
@@ -816,15 +809,13 @@ let commands = {
816
809
  true,
817
810
  );
818
811
  } else {
819
-
820
812
  if (!silent) {
821
813
  logger.info(chalk.dim(`Command output:`), true);
822
- logger.info(`${result.stdout}`, true)
814
+ logger.info(`${result.stdout}`, true);
823
815
  }
824
816
 
825
817
  return result.stdout?.trim();
826
818
  }
827
-
828
819
  } else if (language == "js") {
829
820
  logger.info(chalk.dim(`running js...`), true);
830
821
 
@@ -833,23 +824,26 @@ let commands = {
833
824
  true,
834
825
  );
835
826
 
836
- console.log('')
837
- console.log('------');
838
-
839
- const context = vm.createContext({ require, console, fs, process, fetch });
827
+ console.log("");
828
+ console.log("------");
829
+
830
+ const context = vm.createContext({
831
+ require,
832
+ console,
833
+ fs,
834
+ process,
835
+ fetch,
836
+ });
837
+
838
+ scriptCode = "(async function() {\n" + scriptCode + "\n})();";
840
839
 
841
- scriptCode = '(async function() {\n' + scriptCode + '\n})();';
842
-
843
840
  const script = new vm.Script(scriptCode);
844
841
 
845
842
  try {
846
843
  await script.runInNewContext(context);
847
844
  } catch (e) {
848
845
  console.error(e);
849
- throw new AiError(
850
- `Error running script: ${e.message}`,
851
- true,
852
- );
846
+ throw new AiError(`Error running script: ${e.message}`, true);
853
847
  }
854
848
 
855
849
  // wait for context.result to resolve
@@ -862,8 +856,8 @@ let commands = {
862
856
  stepResult = stepResult.toString();
863
857
  }
864
858
 
865
- console.log('------');
866
- console.log('')
859
+ console.log("------");
860
+ console.log("");
867
861
 
868
862
  if (!stepResult) {
869
863
  logger.info(`No result returned from script`, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "5.7.30",
3
+ "version": "5.7.31",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {