Help with using WASP for testing automation

Aug 18, 2011 at 6:56 AM

Wondering if anyone can help us (noobs)... 

We just starting to use PowerShell with the WASP plug-in to automate a repetitive task in a Windows GUI app.   The script basically needs to:   

  1. Open the program with a data file;   
  2. Fire off a command that performs a data file stress-test (this is a child-window);   
  3. **Check the test result: Pass / Fail (this is a child-window of the child-window);
  4. Write the result to the log file;   
  5. Close the program;   
  6. Repeat for all files in a specified directory. 

Our script does just about all that except "3) Check Test result".

 We haven’t worked out how to distinguish between the two different Pass / Fail dialogs.  That is, once the test has completed, the program will display the result in one of two possible pop-up child windows:   
- A successful test results in a popup window with title "Information" and an "OK" button; or   
- A failed test results in a popup window with title "Delta AT" and an "Stop" button.


Are there any PowerShell commandlets that can get the properties of a popup window, such as the window title, etc, and branch accordingly?
TIA

Paul


Our script so far:
#------------------------

set-executionpolicy Unrestricted
Import-Module C:/install/WASP/wasp.dll 
Clear-Host

$tdxpath = "C:\xl-tdx-20110802\"
$testLog = "C:\xl-tdx-20110802\stresstest.log" 
$filename = "success.tdxex" 

## Step 1: FireUp the Authoring Tool
Write-Host "Loading " $filename
Start-Process C:\xl-at-math\DeltaAT.exe ($tdxpath + $filename) -NoNewWindow
Start-Sleep -s 2

## Step 2: Activate Math Tool, and exectute Stress Test (CTR-ALT-R)
Select-Window DeltaAT* | Set-WindowActive | Send-Keys "^%r" 

#       2a: Click Enter to start the test
Write-Host "Starting Stress test..."
Select-Window DeltaAT* | Set-WindowActive | Send-Keys "{ENTER}" 

#       2b: Wait 10 sec for test to complete. Would be better to check for completion.
Start-Sleep -s 10
Write-Host "Testing Complete"

 

## Step 3: Conditional statement: (**This is where we need help**)
## A successful test will have a dialog box with title "Information" and button labeled "OK"
## A failed test will have a dialog box with title "Delta AT" and button labeled "Stop"

if (Select-Window DeltaAT* | Select -Last 1 | Remove-Window -Passthru | Select-childwindow | select-control -title "OK")
{   
Write-Host "Stress test passed"   
$resultMsg = "PASSED: "   
#Select-Window DeltaAT* | Select -Last 1 | Remove-Window -Passthru | Select-childwindow | select-control -title "OK"  -recurse | Send-Click
}
else
{   
Write-Host "Stress test failed"       
$resultMsg = "FAILED: "   
#Select-Window DeltaAT* | Select -Last 1 | Remove-Window -Passthru | Select-childwindow | select-control -title "Stop"  -recurse | Send-Click
}

# Step 4: Write the result
$output = "$(Get-Date -f o), " + $resultMsg + $filename $output | out-file $testLog -Append

# Step 5:
#      5a: close Dialog
Start-Sleep -s 1
Write-Host "Closing " + $resultMsg + " Dialog"
Select-Window DeltaAT* | Set-WindowActive | Send-Keys "{ENTER}"

#      5b: Close "Variable Stress Test" window"
Write-Host "Closing Variable Stress Test Dialog"
Select-Window DeltaAT* | Select -Last 1 | Send-Keys "%{F4}"

#      5c: Close "Delta AT" window
Write-Host "Closing Delta AT window"
Select-Window DeltaAT* | Select -Last 1 | Send-Keys "%{F4}"
#------------------------