When message boxes occur at replay time, the same action needs to be taken that was taken at recording time. To handle this, the return code is captured at postamble time along with the message box title, message string, and flags. When this combination of parameters is encountered at replay time, the recorded return code is returned.
The runTest method in the profile class declares what message boxes are expected during execution of the class. These declarations are checked at replay time in the reimplemented app.msgBox method. If unexpected message boxes are displayed or expected message boxes are not displayed, the replay fails.
To allow for dynamic content (for example, "Are you sure you want to delete user John Smith?"), a match of the flags is considered close enough, if the message box is displayed at the expected time. A message is logged, showing the expected and actual parameters involved. You could make this algorithm more sophisticated; for example, requiring that the beginning or end of the title or message, or both the title and the message, must also match.