Sunday, February 22, 2009

Reporter.RunStatus

Retrieves the run status at the current point of the run session.
A small example of Reporter.RunStatus:
  1. Open a new test.
  2. Click Record.
  3. Go to Start -> Run, Run window opens.
  4. Type notepad.
  5. Click OK.
  6. A blank notepad opens.
  7. In the notepad, go to File -> Exit
It recorded the following two lines code for me:

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"
ExitAction
End If

So the final code is:

SystemUtil.Run "notepad","","C:\Documents and Settings\sachin",""

If Reporter.RunStatus = micFail Then
msgbox "Exiting an Action"
ExitAction
End If

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"
ExitAction
End If

Window("Notepad").WinMenu("Menu").Select "File;Exit"


Now run the above code it will display the message box and exit the action.