Monday 30 January 2012

QTP Notify: a simple utility designed to display notifications in the system tray

QTP Notify is a simple utility designed to display notifications in the system tray. The purpose of it is to display useful information when a test is executing in way that does not take focus away from the application under test. This can be useful for debugging tests or understanding how far through execution a test is without interfering with the desktop.


Add caption






The download contains 3 files:
  • The application (QTPNotifier.exe)
  • The QTP function that calls the notification (RaiseNotification), and
  • An Example QTP 11 test.

Setting Up

To setup and integrate this with your tests:
  1. Copy the QTPNotifier.exe application to your computer or network drive.
  2. Include the RaiseNotification function in your framework.
  3. Modify the "NPATH" constant in the function so that it points towards the location where you saved QTPNotifier.exe.
  4. In your test scripts call the RaiseNotification function, an example would be: Call RaiseNotification("Title Test","Message Test")
How it works:

The application polls the directory where it's saved to and looks for a text file with the format "<computername>notify.txt". When it finds the file, it reads the first line as the title and the second line as the message. It deletes the file and then displays a notification bubble in the notification area. The QTPNotifier.exe application will stay alive for another 60 seconds and repeat if another message is found. If no notification has been raised in the last 60 seconds the application will naturally terminate.

Things to note:
  1. Theres a small overhead each time you call this whilst the function searches for running processes (might be a second on some machines). This is useful as the QTP Notify application needs messages to have at least 100 milliseconds between each notification.
  2. Sometimes the notification appears behind the current window - this is a known issue with Windows XP, usually a reboot fixes this.
  3. If you are relying on low level mouse moves and clicks then you might click the notification bubble by accident if the mouse is clicked in the bottom right area. You could modify the function to disable itself if a certain environment variable is set.
  4. It's not designed to be robust or perfect...but it does the job for me!

No comments: