About Creating User-Defined Functions - WinRunner

In addition to providing built-in functions, TSL allows you to design and implement your own functions. You can:

  • Create user-defined functions in a test script. You define the function once, and then you call it from anywhere in the test (including called tests).
  • Create user-defined functions in a compiled module. Once you load the module, you can call the functions from any test. For more information, see “Creating Compiled Modules.”
  • Call functions from the Microsoft Windows API or any other external functions stored in a DLL. For more information, see “Calling Functions from External Libraries.”

User-defined functions are convenient when you want to perform the same operation several times in a test script. Instead of repeating the code, you can write a single function that performs the operation. This makes your test scripts modular, more readable, and easier to debug and maintain.

For example, you could create a function called open_flight that loads a GUI map file, starts the Flight Reservation application, and logs into the system, or resets the main window if the application is already open.

A function can be called from anywhere in a test script. Since it is already compiled, execution time is accelerated. For instance, suppose you create a test that opens a number of files and checks their contents. Instead of recording or programming the sequence that opens the file several times, you can write a function and call it each time you want to open a file.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

WinRunner Topics