May 31, 2008

WinRunner Hidden Coding Features


WinRunner has certain features that are not commonly known. This is a list with the most powerfull ones:

print {statement};
In non-batch mode, this will print the outcome of a statement/variable or string to an output screen. Great for debugging and much faster (and less annoying) then the pause() function. This function is not documented in the help files, only as a registered word (a word you can not use as a name for a custom variable or function).

sprintf(format, variable, ...);
This function works like the (s)printf in C, but without an out variable. The return value is the formatted string.

Example:
percCompl = 78.22845;
A = sprintf(“Completed: %0.2f%%”, percCompl);
# A == “Completed: 78.23%”
For a complete overview of format characters, search the internet on sprintf() or get a C/C++ guide.

Although this function can be found in the WinRunner users guide, it is highly underestimated. It works great for getting "check" variables in the correct formatting without bothering string manipulation.

Use Add Watch as direct execution window
Use the Add Watch to see variable values during runtime and/or after pausing a test.
While pausing a test, you can enter direct functions into the add watch window and evaluate the return value. So you can check during runtime if objects are existing and if certain functions are working properly. The shortcut to Add Watch is CTRL+w.

Use the call chain in the Debug menu function to find out function callers and callies.
Within the callchain, you can jump from and to functions that are on the call chain; the values of the variables are still in place and you can use add watch to evaluate them (see section above).

You can also use the call_chain_get_depth() and call_chain_get_attribute() WinRunner functions to write extensive debugging information to a log file. When you are used to the try/catch mechanism, you will certainly appreciate these two functions.