A small example of Reporter.RunStatus:
- Open a new test.
- Click Record.
- Go to Start -> Run, Run window opens.
- Type notepad.
- Click OK.
- A blank notepad opens.
- In the notepad, go to File -> Exit
SystemUtil.Run "notepad","","C:\Documents and Settings\sachin",""
Window("Notepad").WinMenu("Menu").Select "File;Exit"
I added the following 4 lines in between these above two lines
If Reporter.RunStatus = micFail Then
msgbox "Exiting an Action"End If
ExitAction
So the final code is:
SystemUtil.Run "notepad","","C:\Documents and Settings\sachin",""
If Reporter.RunStatus = micFail Then
msgbox "Exiting an Action"End If
ExitAction
Window("Notepad").WinMenu("Menu").Select "File;Exit"
Run this whole above code it will work fine and pass.
Now remove any character from "notepad" from the first line so as to intentionally fail the test so that we can see the Reporter.RunStatus working (I removed the last ‘d’ in notepad). I have also intentionally added an “On error Resume Next” line in order to suppress any errors.
On Error Resume Next
SystemUtil.Run "notepa","","C:\Documents and Settings\sachin",""
If Reporter.RunStatus = micFail Then
msgbox "Exiting an Action"End If
ExitAction
Window("Notepad").WinMenu("Menu").Select "File;Exit"
Now run the above code it will display the message box and exit the action.