Reputation: 415
I'm working on some automation testing for a test app I developed. Using Powershell, I need to identify if a certain instance of the application is running. Currently, I can only find out ways to determine if the Application itself is running, not a specific instance of the application.
For example, see picture below:
The "SDX Test App" is the application itself. From the picture, you can see there's two instance of the test app (the top one is an error popup dialogue).
I need a way through Powershell to detect if the "Assertion Failure" instance is running.
When I right click on that instance, there is no option for "Properties" or anything like that.
Does anyone have a method of checking this? It would be much appreciated!
Upvotes: 0
Views: 361
Reputation: 5351
You could try using the MainWindowTitle
and/or CommandLine
properties to differentiate between processes with the same name:
# List the different instances of notepad++
Get-Process -Name notepad++ | Select-Object ProcessName,MainWindowTitle,CommandLine
ProcessName MainWindowTitle CommandLine
----------- --------------- -----------
notepad++ C:\A\A.txt - Notepad++ "C:\Program File…"
notepad++ C:\B\B.txt - Notepad++ "C:\Program File…" "C:\B\B.txt"
From there you can write a basic test. For example:
# Check for assertion failure window:
if ( (Get-Process -Name "SDX Test App").MainWindowTitle -like "Assertion Failure*" ) {
Write-Output "It's running!"
}
Upvotes: 3