Monday, December 26, 2016

Micro Focus UFT - HP QTP - AUTIM Descriptive Programming Object repository in VB Script

AUTIM Descriptive Programming Object repository in VB Script
Dt: 08/11/2014

1.1How to Capture object properties in Vbs file?

All AUTIM application’s objects properties should be captured in the file AUTIM_VbsObjRep.vbs. In the main function called “AppMainFunc(), we will pass two parameters, ObjClass and ObjAliasName (eg. AppMainFunc(ObjClass,ObjAliasName).
Using ObjClass parameter we pass the exact "Class name" property value of any object ( Pbwindow, Window, PbObject, Pbedit.......)

Sample code of AUTIM_ObjRep.vbs
REM Object repository For AUTIM
ArrayDec = 400         REM 400 is the Maximum array range.
Public Function AppMainFunc(ObjClass,ObjAliasName)
    ObjName 
= Split(Trim(ObjAliasName),",")                REM Splitting the ObjAliasName with "," Delimiter    
    ObjClassName 
= ObjName(0)                              REM ObjClassName - Contains the alias name
    
REM Splitting the Classname with "," Delimiter and assign it to AppObjType
    AppObjType 
= Split("PbWindow,Window,PbObject,PbEdit,PbList,PbButton,PbLabel,10,winbutton,wincombobox,dialog,WinEdit,WinList,WinObject,VbWindow,ActiveX,WinRadioButton,PbEditor"",")
    
REM Array Declaration for function - All the functions are stored in array
    ObjFunc 
= Array("SrchMainWin(Objclassname)","SrchWdw(Objclassname)","SrchPbObj(Objclassname)","SrchPbEdit(Objclassname)","SrchPbList(Objclassname)","SrchPbBtn(Objclassname)","SrchPbLbl(Objclassname)","SrchWinBtn(Objclassname)","SrchWinCombx(Objclassname)","SrchWinDlg(Objclassname)","SrchWinedit(Objclassname)","SrchWinList(Objclassname)","SrchWinObject(Objclassname)","SrchVbWindow(Objclassname)","SrchActiveX(Objclassname)","SrchWinRdBtn(Objclassname)","SrchPbEditor(Objclassname)")
   
REM The below code will search for the "Class Name" and it will call the respective function
    
For i = 0 To UBound(AppObjType)
        
If LCase(AppObjType(i)) = LCase(Objclass) Then
            Objppt 
= Eval(ObjFunc(i))
            
Exit For
        
End If
    
Next
If LCase(Objppt) <> "fail" Then
Set AppObj = Description.Create
Objppt1 = Split(Objppt,",")
For i = 0 To UBound(Objppt1)
Objppt2 = Split(Objppt1(i),":=")
If UBound(Objppt2) > 1 Then
AppObj(Trim(Objppt2(0))).value = Trim(Objppt2(1))&":"
Else
AppObj(Trim(Objppt2(0))).value = Trim(Objppt2(1))
End IF
Next
Set AppMainFunc = AppObj
Else
Set AppObj = Description.Create
Set AppMainFunc = AppObj
    End If    End Function
REM Sample code of AUTIMObjRep for Main window - REM This function (Array(1)) is to add all Pbwindow Poperties.
Public Function SrchMainWdw(srchwinwdwtxt)
ReDim mwdw(ArrayDec,1)
mwdw(0,0)="MainAppWindow"
mwdw(0,1)="Class Name:PbWindow,nativeclass:= FNWNS390,text:=Welcome.*,pbname:=w_login"

Mainwdw = Checkppt(mwdw,srchwinwdwtxt)
Erase mwdw
SrchMainWdw = Mainwdw
End Function

REM Checkppt is the function to search for the Alias name in the array.
Public Function Checkppt(ValArray,srchtxt)
    val 
=""
    
For i = 0 To UBound(ValArray)
        
If LCase(ValArray(i,0)) = LCase(srchtxt) Then
            val 
= ValArray(i,1)
            
Exit For
        
End If
    
Next
    
REM    When alias name is found it return the property for that object, else it returns fail.
    
If val <> "" Then
        Checkppt 
= val
        
Else
            Checkppt 
="Fail"
    
End If        End Function

1.2How to write script using AUTIM_vbsObjRep.vbs in UFT?

AUTIMObjRep.vbs contains the object properties of AUTIM application. We use AUTIMObjRep.vbs to write any action script. (eg. Launch application, Create member … close application.
Sample Script to launch application:
LaunchAUTIM()
Public Function LaunchAUTIM()
   
SystemUtil.Run "C:\AUTIM\Testing\HDSVIEW.bat"," ","C:\AUTIM\Testing\",""
    
Set oMainWin = PbWindow(AppMainFunc("PbWindow","MainAppWindow"))
   
Do Until oMainWin.Exist(7)
         
Wait(1)
   
Loop

    If oMainWin.Exist(7) then
        Reporter.ReportEvent 
0"Window Availablility""Window is Available"
    
Else
        Reporter.ReportEvent 
1"Window Availablility",  "Window is NOT Available"
    
End if
End Function

1 comment:

  1. Hi All, if you want more clarity about AUTIM Descriptive Programming Object repository in VB Script, post you questions I will answer it!

    ReplyDelete