testdriverai 4.0.19 → 4.0.21

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/commands.js CHANGED
@@ -27,6 +27,9 @@ class AiError extends Error {
27
27
  this.attachScreenshot = attatchScreenshot;
28
28
  }
29
29
  }
30
+
31
+ const commandOrControl = process.platform === 'darwin' ? 'command' : 'control';
32
+
30
33
  const findImageOnScreen = async (relativePath, haystack, restrictToWindow) => {
31
34
  let displayMultiple = await getDisplayMultiple();
32
35
 
@@ -445,8 +448,7 @@ let commands = {
445
448
 
446
449
  try {
447
450
  // use robot to press CMD+F
448
- await robot.keyTap('f', 'command');
449
- await robot.keyTap('command');
451
+ await robot.keyTap('f', commandOrControl);
450
452
  // type the text
451
453
  await robot.typeString(text);
452
454
  await redraw.wait(2000);
@@ -2,14 +2,18 @@
2
2
  const path = require("path");
3
3
  const { execSync } = require("child_process");
4
4
  const { platform } = require("./system");
5
+ const scriptPath = path.join(__dirname, "focusWindow.ps1");
5
6
 
6
7
  // apple script that focuses on a window
7
8
  const appleScriptShow = (windowName) => `
8
- tell application "${windowName}" to set miniaturized of every window to false
9
- `;
9
+ tell application "System Events" to tell process "${windowName}"
10
+ set frontmost to true
11
+ end tell`;
10
12
 
11
13
  const appleScriptHide = (windowName) => `
12
- tell application "${windowName}" to set miniaturized of every window to true`;
14
+ tell application "System Events" to tell process "${windowName}"
15
+ set frontmost to false
16
+ end tell`;
13
17
 
14
18
  async function focusApplication(appName) {
15
19
  try {
@@ -20,7 +24,6 @@ async function focusApplication(appName) {
20
24
  // TODO: This needs fixing
21
25
  return await execSync(`wmctrl -a '${appName}'`);
22
26
  } else if (platform() == "windows") {
23
- const scriptPath = path.join(__dirname, "focusWindow.ps1");
24
27
  return await execSync(`powershell "${scriptPath}" "${appName}" -Action "Show"`);
25
28
  }
26
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "4.0.19",
3
+ "version": "4.0.21",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {