R. E. Cook
Home 
Contact Us 

Dr. Cook
Resume 

RunningShoes Library for WinRunner 
RunningShoes 

Custom WinRunner Functions 
and Utilities,
to Your Specs
Custom 

A Random Collection of WinRunner Solutions
Solutions 

Creating DLLs for WinRunner 
"DLLs Demystified" 
(Mercury Interactive's Worldwide Users Conference 2000)

Determine the version of WinRunner at runtime

 

I've had several requests for a function that will determine the version of WinRunner at runtime. 

(Although it might seem odd at first glance that a user could be running WinRunner without knowing what version it is, some test environments maintain more than one version concurrently, on different PCs. A script can be tailored to use different versions if it can tell at runtime which WinRunner version is running. For example, in an environment with WinRunner 6 and 7, functions that were not implemented until version 7 can be called only when running under version 7, and be skipped under version 6.)


The smart way

The version is stored in wrun.ini, under [WrCfg], as XR_VERSION_STAMP. Thus the value can be read using getvar():

# Retrieve the version of WinRunner.
rc = getvar("XR_VERSION_STAMP");

See Reading WinRunner configuration values for a general discussion of reading from wrun.ini.


The dumb way

WinRunner stores version information in the file WinRunner\dat\version.dat. The file is a text file, so you can read it with WinRunner's file_ functions. The first line contains the version number. 

For example, in version 6.02, version.dat contains the following three lines:

   6.02
   6089
   Build 6089


NOTE: The version.dat file is undocumented, so the possibility exists that it can be changed or even discarded in a future version of WinRunner. When using undocumented features of any program, verify that they work before relying on them.


Function code

The code is implemented as a function (put it in a compiled module, of course). Call it like this:

# Capture the WinRunner version.
rc = WinRunnerVersion(version);

# Limit execution to version 7 or greater.
if(version >= 7.0)
{
    # Execute code not implemented before version 7.
    ...
}

 



Top of  This Page | R. E. Cook Home Page

Copyright R. E. Cook Consulting, 2000 - 2011.
All rights reserved.

The site is designed to look best when viewed with Internet Explorer 5.0 - 8.0. Results with other browsers will probably deviate from what is intended.

NOTE: This website refers to registered trademarks and service marks that are owned by other companies, including Mercury Interactive, WinRunner, TestDirector, TSL, Microsoft, Windows.