Monday, March 24, 2008

Class Mapping in Winrunner

Class Mapping concept is explained in Custom Objects . Winrunner (WR) also provides class mapping. The Class Mapping enables you to map a custom class to a Standard class.

You can map the classes by two ways.


  • By using Winrunner editor. Use GUI Map editor from Tools Menu.

  • By setting dynamically through TSL (Test Script language) code. See following code snippet.


Code:


#-------------------------------------------------------------------------
# Method : WindowsCustomTextbox
# Author : T.Palani Selvam
# Purpose : It directs the execution according to actions in text box & mapping with given class.
# Parameters:
# sCtrlName - contains name of that control.
# sAction - contains type of the action should be happened.
# sData - contains data to be checked or played in controls.
# sCustomClass - contains class name to be mapped.
# Returns : Integer - returns int value (TRUE = 1 or non-Zero, FALSE = 0)
# Caller :
# Calls : - Nil -
#Logical expressions are assigned the value 1 if true, and 0 if false - From TSL Reference.
#-------------------------------------------------------------------------
public function WindowsCustomTextbox(in sCtrlName,in sAction,in sData, in sCustomClass) {
auto sResult;
auto sMappedClass;
auto sLocation;

get_class_map(sCustomClass , sMappedClass); #Get mapped Class name.
#Verify thr control name type.
sLocation = IdentifyType(sCtrlName);
if (sLocation != "") {
sCtrlName = "{class: edit,MSW_class: " & sCustomClass & ",location: " & sLocation & " }";
}

if (sMappedClass != "edit") {
set_class_map(sCustomClass , "edit"); #Mapping.
sResult = WindowsTextbox(sCtrlName,sAction,sData);
unset_class_map(sCustomClass); #released mapping.
}else {
sResult = WindowsTextbox(sCtrlName,sAction,sData);
}
return sResult;

} #end of function WindowsCustomTextbox

No comments: