PowerShell
$output = & $nunitLocation $testDll --test=$testCaseName 2>&1param($variables, $tempDir, $aquaCallback)# Sample PowerShell script that uses .NET objects and TC variables from aqua
param($variables, $tempDir, $aquaCallback)
$text = new-object System.Text.StringBuilder
$date = [System.DateTime]::Now
$text.AppendLine($date.ToLongDateString())
$text.AppendLine($date.ToLongTimeString())
echo "$text" > script-sample.log
foreach ($var in $variables)
{
$varName = $var.Name
$varValue = $var.Value
echo "Variable: $varName : $varValue" >> script-sample.log
}
# Possible Types of [aqua.ProcessEngine.WebServiceProxy.ExecutionLogMessageType]
# SUTError, ScriptExecutionError, PreparationError, ExecutionError, InformationalInfo, InformationalDebug, InformationalWarn, InformationalSuccess
$aquaCallback.SendMessage("hello, I was sent from script", [aqua.ProcessEngine.WebServiceProxy.ExecutionLogMessageType]::InformationalWarn, "my category");
$aquaCallback.SendMessageWithScreenshot("and this is Screenshot", "c:\sample.jpg", [aqua.ProcessEngine.WebServiceProxy.ExecutionLogMessageType]::InformationalWarn, "my category");
dir $tempDir >> script-sample.log
$aquaCallback.AddExecutionAttachment("script-sample.log");
while ($true)
{
if ($aquaCallback.StopRequest)
{
$aquaCallback.SendMessage("Aborting on StopRequest", [aqua.ProcessEngine.WebServiceProxy.ExecutionLogMessageType]::InformationalWarn, "my category");
return "Aborted"
}
Start-Sleep -s 10
aquaCallback.SendMessage("Looping in PowerShell…", [aqua.ProcessEngine.WebServiceProxy.ExecutionLogMessageType]::InformationalWarn, "my category");
}
# Return status of script execution. One of: Ready, Blocked, Fail, Aborted
return "Ready" Execution Status
Last updated
Was this helpful?