Monday, May 11, 2015

ExecuteFile method

Executefile method is used to run the functions which are saved in .vbs file

If you want to call a functions for the private\single script or action, use executefile method.
here note that we are not associating library file/Functions (Library file is one which contains all the functions and saved in .vbs format) to the QTP.

Advantage :
No need to associate the library files to the QTP

Dis-Advantage :
The called function is always applicable to the that particular script or action only. In other word the called function will not be a global.

Syntax is :
ExecuteFile "path of the .vbs file"



--- source: http://www.automationrepository.com/2011/09/associate-function-library-to-qtp-script/

Using ExecuteFile Method: One of the 4 methods that will help you in associating the function libraries in QTP Test Cases.
ExecuteFile statement executes all the VBScript statements in a specified file. After the file has been executed, all the functions, subroutines and other elements from the file (function library) are available to the action as global entities. Simply put, once the file is executed, its functions can be used by the action. You can use the below mentioned logic to use ExecuteFile method to associate function libraries to your script.
 
'Action begins
ExecuteFile "C:\YourFunctionLibrary.vbs"
'Other logic for your action would come here
'.....





Example: (working)

Action1:
 'Import the file "hi-function.vbs"
ExecuteFile "C:\Users\sxkulkar\Desktop\hi - funciton.vbs"
 ' "hi" is a function in the above imported file, this function is 'called directly without writing it again in Action1. 
Call hi




 

1 comment: