testdriverai 4.0.18 → 4.0.19

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 CHANGED
@@ -91,8 +91,9 @@ const thisCommand = a.command;
91
91
  log.log('info', chalk.green(`Howdy! I'm TestDriver v${package.version}`))
92
92
  log.log('info', chalk.dim(`Working on ${thisFile}`))
93
93
  console.log('')
94
+ log.log('info', chalk.yellow(`This is beta software!`))
94
95
  log.log('info', `Join our Discord for help`);
95
- log.log('info', chalk.yellow(`https://discord.com/invite/cWDFW8DzPm`));
96
+ log.log('info', `https://discord.com/invite/cWDFW8DzPm`);
96
97
  console.log('')
97
98
 
98
99
  // individual run ID for this session
@@ -573,22 +574,15 @@ let setTerminalWindowTransparency = async (hide) => {
573
574
  try {
574
575
  if (hide) {
575
576
 
576
- if (terminalApp) hideTerminal(terminalApp);
577
+ if (terminalApp) {
578
+ hideTerminal(terminalApp)
579
+ };
577
580
 
578
- // http.get('http://localhost:60305/hide', (res) => {
579
- // // Handle response if needed
580
- // }).on('error', (err) => {
581
- // // console.error('Error:', err);
582
- // });
583
581
  } else {
584
582
 
585
- if(terminalApp) showTerminal(terminalApp);
586
-
587
- // http.get('http://localhost:60305/show', (res) => {
588
- // // Handle response if needed
589
- // }).on('error', (err) => {
590
- // // console.error('Error:', err);
591
- // });
583
+ if(terminalApp) {
584
+ showTerminal(terminalApp);
585
+ }
592
586
  }
593
587
  } catch (e) {
594
588
  // Suppress error
package/lib/commands.js CHANGED
@@ -132,6 +132,7 @@ const assert = async (assertion, shouldThrow = false, async = false) => {
132
132
 
133
133
  const handleAssertResponse = (response) => {
134
134
  if (response.indexOf('The task passed') > -1) {
135
+ logger.prettyMarkdown(response)
135
136
  return true;
136
137
  } else {
137
138
  if (shouldThrow) {
@@ -5,16 +5,11 @@ const { platform } = require("./system");
5
5
 
6
6
  // apple script that focuses on a window
7
7
  const appleScriptShow = (windowName) => `
8
- tell application "System Events" to tell process "${windowName}"
9
- set frontmost to true
10
- end tell
8
+ tell application "${windowName}" to set miniaturized of every window to false
11
9
  `;
12
10
 
13
11
  const appleScriptHide = (windowName) => `
14
- tell application "System Events" to tell process "${windowName}"
15
- set frontmost to false
16
- end tell
17
- `;
12
+ tell application "${windowName}" to set miniaturized of every window to true`;
18
13
 
19
14
  async function focusApplication(appName) {
20
15
  try {
@@ -26,7 +21,7 @@ async function focusApplication(appName) {
26
21
  return await execSync(`wmctrl -a '${appName}'`);
27
22
  } else if (platform() == "windows") {
28
23
  const scriptPath = path.join(__dirname, "focusWindow.ps1");
29
- return await execSync(`powershell "${scriptPath}" "${appName}"`);
24
+ return await execSync(`powershell "${scriptPath}" "${appName}" -Action "Show"`);
30
25
  }
31
26
 
32
27
  } catch (error) {
@@ -35,11 +30,13 @@ async function focusApplication(appName) {
35
30
  }
36
31
 
37
32
  async function hideTerminal(appName) {
33
+
38
34
  try {
39
35
  if (platform() == "mac") {
40
36
  return await execSync(`osascript -e '${appleScriptHide(appName)}'`);
41
37
  } else if (platform() == "linux") {
42
38
  } else if (platform() == "windows") {
39
+ return await execSync(`powershell "${scriptPath}" "${appName}" -Action "Minimize"`);
43
40
  }
44
41
  } catch (error) {
45
42
  console.log(error);
@@ -53,6 +50,7 @@ async function showTerminal(appName) {
53
50
  return await execSync(`osascript -e '${appleScriptShow(appName)}'`);
54
51
  } else if (platform() == "linux") {
55
52
  } else if (platform() == "windows") {
53
+ return await execSync(`powershell "${scriptPath}" "${appName}" -Action "Show"`);
56
54
  }
57
55
 
58
56
  } catch (error) {
@@ -11,10 +11,14 @@ Add-Type @"
11
11
  }
12
12
  "@
13
13
 
14
- function Bring-WindowToFront {
14
+ function Control-Window {
15
15
  param(
16
16
  [Parameter(Mandatory=$true)]
17
- [string]$ProcessName
17
+ [string]$ProcessName,
18
+
19
+ [Parameter(Mandatory=$true)]
20
+ [ValidateSet("Minimize", "Show")]
21
+ [string]$Action
18
22
  )
19
23
 
20
24
  $processes = Get-Process | Where-Object {
@@ -29,18 +33,25 @@ function Bring-WindowToFront {
29
33
  foreach ($proc in $processes) {
30
34
  $hwnd = $proc.MainWindowHandle
31
35
 
32
- # Check if the window is minimized
33
- if ([User32]::IsIconic($hwnd)) {
34
- # If minimized, restore the window
35
- [User32]::ShowWindowAsync($hwnd, 9) | Out-Null
36
+ if ($Action -eq "Minimize") {
37
+ # Minimize the window
38
+ [User32]::ShowWindowAsync($hwnd, 6) | Out-Null # 6 is SW_MINIMIZE
39
+ Write-Host "Minimized '$($proc.MainWindowTitle)'."
40
+ }
41
+ elseif ($Action -eq "Show") {
42
+ # Check if the window is minimized
43
+ if ([User32]::IsIconic($hwnd)) {
44
+ # If minimized, restore the window
45
+ [User32]::ShowWindowAsync($hwnd, 9) | Out-Null # 9 is SW_RESTORE
46
+ }
47
+
48
+ # Bring the window to the foreground
49
+ [User32]::SetForegroundWindow($hwnd) | Out-Null
50
+ Write-Host "Brought '$($proc.MainWindowTitle)' to the foreground."
36
51
  }
37
-
38
- # Bring the window to the foreground
39
- [User32]::SetForegroundWindow($hwnd) | Out-Null
40
-
41
- Write-Host "Brought '$($proc.MainWindowTitle)' to the foreground."
42
52
  }
43
53
  }
44
54
 
45
55
  # Usage example:
46
- Bring-WindowToFront -ProcessName $args[0]
56
+ # Control-Window -ProcessName "notepad" -Action "Minimize"
57
+ # Control-Window -ProcessName "notepad" -Action "Show"
package/lib/init.js CHANGED
@@ -142,6 +142,6 @@ module.exports = async () => {
142
142
  console.log(chalk.green('Testdriver setup complete!'));
143
143
  console.log('');
144
144
  console.log(chalk.yellow('Create a new test by running:'));
145
- console.log(chalk.dim('testdriverai testdriver/test.yml'));
145
+ console.log('testdriverai testdriver/test.yml');
146
146
 
147
147
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "4.0.18",
3
+ "version": "4.0.19",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {