Saturday 16 August 2014

Utility Functions Using QTP for Siebel Complex Control Objects


Introduction

This document is intended to give some brief on writing the utility functions for basic functionalities of Siebel complex control objects using QTP. We have written the few basic library functions for Siebel complex controls such as Sieblist, SiebCalendar and siebcalculator. In automation, it is important to automate the basic functionalities to ensure that the particular object is present then do appropriate actions upon it. In this document we would like to share utility scripts for complex controls (siebPicklist, siebCalendor, siebList and siebcalculator) and script to connect to oracle database to manage the test data in the siebel database.

 

Complex Control Objects:

Following are complex controls that appear in the Siebel application.


Utility functions for siebcalculator, SiebCalendar, SiebList and SiebPickList are covered in this BOK.

These objects are the quite complex controls present in most of the siebaplets in Siebel application. Since the occurrence of these objects is more, utility functions for these objects will be more efficiently reused. Following check points are covered in the below mentioned function libraries.

 

1. Set the control object to logical name.

2. Check if object exists. If the object exists, select the object.

3. If the object does not exist, raise an error message. 


Advantage:

 

These scripts can be reused in any script by supplying appropriate input data.


Script for siebPickList: The siebPickList object is a child of the SiebApplet Object, SiebList Object, and SiebCurrency Object. So following utility functions can be associated to the scripts having its parent objects siebApplet object, Sieblist object and SiebCurrency object.

-----------------------------------------------------------------------------------------------

Input Parameter       : objSiebApplet (Object) - representing Siebel Applet object

                               uListObject - representing the logical name of siebPickList object

                               uData - representing the data to be selected from pick List

Return Value            : True /False

-----------------------------------------------------------------------------------------------

Public Function selectingSiebPickList(Byval, uPickListObject, Byval uData)

                ‘On Error Resume Next

Dim uCount

Call getObjectProperties( "SiebPickList ",uPickListObject,4)

Set objControlRef = objSiebApplet.SiebPicklist(uPickListObject)

objControlRef.sync
If objControlRef.Exist = False then
Reporter.ReportEvent micFail, "Error Message", "SiebPickList object is not available."
retResult = False                                  
           Else
                       retResult=true
                      If uData = "#1" then
                      uCount = objControlRef.Count
 For i = 0 to uCount -1
If  i =0 Then
vItem = objControlRef.GetItemByIndex(i)
objControlRef.Select vItem
writeLogfile("In the SiebPickList " & uPickListObject & " First Item " & vItem  & "  is Selected. " )
Exit For
End If
Next
Else
objControlRef.Select uData
writeLogfile("In the SiebPickList " & strPickListObject & " Item " & strData  & "  is Selected. " )
End If
End if
selectingSiebPickList=retResult
End Function

Script for SiebList

 ---------------------------------------------------------------------------------------------------------------------------------- 
'Input Parameter        uSiebList- representing the logical name of SiebList
'Description                        Returns the rows count of the siebList.
'Calls                                      error Handler in case of any error
'Return Value                     Rows count
'----------------------------------------------------------------------------------------------------------------------------------
Public Function getSiebListRowCount(Byval uSiebList)
On Error Resume Next
Dim uCount
Dim strRepositoryName,uTempSearchOut
'Call getObjectProperties( "SiebList",uSiebList,4)
Set objControlRef = objSiebApplet.SiebList(uSiebList)
objControlRef.sync
If objControlRef.Exist = False then
Reporter.ReportEvent micFail, "Error Message", "SiebPickList object is not available."
   Else
          uRepositoryName = objControlRef.RowsCount
  '  strTempSearchOut = objControlRef.GetCellText(uRepositoryName,0)
          End if
           getSiebListRowCount= uRepositoryName
  End Function

Script for SiebCalculator:

The SiebCalculator object is a child of the SiebApplet Object, SiebList Object, and SiebCurrency Object. So following utility functions can be associated to the scripts having its parent objects siebApplet object, Sieblist object and SiebCurrency object

---------------------------------------------------------------------------------------------------------------------------------------
'Input Parameter                strSiebToolbar (String)    - Logical name of SiebToolbar Object
'Description              sets the SiebToolbar object to logical name & checks whether object exists and clicks the toolbar item                                     
'Calls                                error Handler in case of any error
'Return Value           True /False
'---------------------------------------------------------------------------------------------------------------------------------------
public Function getSiebCalculator(usiebApplet,uSiebCalculator,uData)
On Error Resume Next
Call getObjectProperties( "Sieb Calculator",strSiebCalculator,4)
Set objControlRef  = objSiebApplet.SiebCalculator(uSiebCalculator)
objControlRef.sync
If objControlRef.Exist = False then
Reporter.ReportEvent micFail, "Error Message", "SiebCalendar object is not available."
retResult = False
Else
 retResult = true
 objControlRef.SetText strData
 uLogString = "SiebCalculator " & strSiebCalculator & " Exists. "
 writeLogFile(uLogString)
End if
 getSiebCalculator = retResult
End Function


Script for SiebCalendar:

The SiebCalendar object is a child of the SiebApplet Object, SiebList Object, and SiebCurrency Object. So following utility functions can be associated to the scripts having its parent objects siebApplet object, Sieblist object and SiebCurrency object.

--------------------------------------------------------------------------------------------
Input Parameter       objSiebApplet (Object) - representing siebel Applet object
                              strEditObject (String) - representing the logical name of SiebText object
Description                        sets the SiebCalendar object to logical name & checks whether
object exists. If the object exists, the Popup method opens the object and     selects the value and closes the object.
Calls                                 error Handler in case of any error
Return Value            True /False
-------------------------------------------------------------------------------------------------------------------------
Public Function selectSiebCalendar(Byval uEditObject)
On Error Resume Next
Dim currentYear
Dim currentMonth
Dim currentDay
Dim currentTime
Dim uCalenderType
' Call getObjectProperties( "SiebCalendar",strEditObject,4)
Set objControlRef = objSiebApplet.SiebCalendar(uEditObject)
objControlRef.sync
If objControlRef.Exist = False then
Reporter.ReportEvent micFail, "Error Message", "SiebCalaendar object is not available."
retResult = False
Else
 retResult=true
currentYear = Year(Now)
 currentMonth = Month(Now)
 currentDay = Day(Now)
 currentTime = Hour(Now) & Minute(Now) & Second(Now)
 uCalenderType = objControlRef.CalendarType
 If  uCalenderType = "DateTimeZone"Then
objControlRef.OpenPopup
objControlRef.SetYear currentYear
objControlRef.SetMonth currentMonth
objControlRef.SetDay currentDay
objControlRef.SetTime currentTime
objControlRef.SelectTimeZone "(GMT-07:00) Mountain Time (US &Canada)"
objControlRef.ClosePopup
'writeLogfile("SiebCalendar TextBox " & uEditObject & " Exists" )
End If
End If
selectingSiebCalendar = retResult
End Function


Pulling Data from a Siebel Table

If you want to pull out all the visible data from a SblTable or a Sieb tabular object (such as a SiebList object) into an external file, you can loop through each cell in the table and then save the information to an external file.

 

                Public Function Retrivedatasiebeltable(Byval usiebList,urowcount,ucolumncount)

For i=0 to urowcount
For j=0 to ucolumncount
Set objControlRef = objSiebApplet.SiebList(uSiebList)
Dat=objControlRef.GetCellData (i, j)
SaveToExternalFile (Dat)
Next
Next


Siebel Database Connection using QTP:

Following script is used to connect the database and insert the data which will be used for testing. Basically this script is used to populate the test data. Similarly one can write functions to update the data in the database, to retrieve the data to test if the correct data is loaded in to the database or not.


Public Function  InsertData(dbStatus,dbSubStatus,dbOrderNumber,dbServiceId)
UID = datatable(“Userid”,dtGlobalsheet).value
Pwd = datatable(“Pwd”,dtGlobalsheet).value

ConnectionString="Provider=MSDAORA.1;User ID=”UID”; Password=”Pwd”;
Data Source=Datasource;Persist Security Info=False"
Set DBobjconn=Createobject("ADODB.Connection")
          DBobjconn.ConnectionString
                DBobjconn .open
          If  DBobjconn is Nothing Then
                   InsertData="DBcouldnotbeconnected"
          Else
                   Dim  dbTableName
                   dbOutputId=DataTable("OutputID",dtGlobalsheet)
             If Not dbOutputId ="" Then
            dbDataId=dbOutputId
                   Else
                             dbDataId=DataTable("InputID",dtGlobalsheet)
                   End If
                   dbEnvironment=Ucase(DataTable("Environment",dtGlobalsheet))
              dbTableName="DATA_BANK"
              dbCreatedBy=DataTable("User_ID",dtGlobalSheet)
                   dbExcel=DataTable("ExcelFileName",dtGlobalSheet)
                   DbArray = Split(dbExcel, "-", -1, 1)
                    dbStreetNumber=DataTable("StreetNumber",dtGlobalSheet)
                     dbPostCode=DataTable("PostCode",dtGlobalSheet)
                   strCAD=" "
                   dbInsertQuery="Insert into "& dbTableName &"(Data_Id,Status ,SubStatus,Order_Number,Service_Id,Created_By,Modified_Date,Environment,SCHEDULE_ID,PostCode,StreetNumber,CEASE_CADATE) Values('"&dbDataId&"','"&dbStatus&"','"&dbSubStatus&"','"& dbOrderNumber&"','"&dbServiceId&"','"&dbCreatedBy&"',SYSDATE,'"&dbEnvironment&"','"&dbArray(0)&"','"&dbPostCode&"','"&dbStreetNumber&"','"&dbCAD&"')"

                   DBobjconn.Execute (strInsertQuery)
                   DBobjconn.Execute ("Commit")
                   InsertData=True
          End If
          DBobjconn.Close
End Function



0 comments :

Post a Comment