Relevant Codes (by Anshoo Arora)

A Test Development Resource for HP QuickTest Professional.

QTP: Working with SiebList

by Anshoo Arora on August 10, 2009

This article has been revised for Siebel Version 8.1. It can be found here

According to Testing Siebel Business Applications at Oracle, “A SiebList object is a singleton container object that is one of the Complex Control Objects. Due to the complex nature of this object, it is also a collection object”. This object can be quite complex to work with, especially when you take into consideration some of the current limitations (I am using Sieb v7.7) found at the KB. Two more limitations can be found in this thread at AdvancedQTP Forums.

Also, when there are many rows present in this object, it may not show the exact number, but instead it shows 1-10+ rows, 11-20+ rows, 21-30+ rows and so on. To get the correct number of rows from the List object, we use an interesting property known as a RecordCounter. A SiebList’s RecordCounter indicates the visible text of the record counter string (for example: 1-10 or 10+).

The idea is to stay in a loop until the “+” sign stops to appear.

Finding the Row Count for SiebList

Option Explicit 'On

'—————————————————————————————————————————
' Name: GetSiebListRows
' 
' Purpose: Get the total number of rows of the List Object without the 
' 1 of 10+, '11 of 20+' and so on..
' 
' Input:
'  oSiebApplet - object reference to the SiebApplet hierarchy
'  pValUINameSiebList - uiname of the SiebList object
' 
' Output: 
'  Integer - number of rows
' 
' Date: 
' 
' Author: 
'—————————————————————————————————————————
Function GetSiebListRows( byRef oSiebApplet, pValUINameSiebList )
'—————————————————————————————————————————
  'SiebList is a list object in a Siebel test automation environment

  Dim vCounter
  If InStr(1, pValUINameSiebList, "uiname") <> 0 Then
    pValUINameSiebList = Trim(Split(pValUINameSiebList, ":=")(1))
  End If
 
  'From QTP Ref:
  '_ The RecordCounter indicates the visible text of the record counter 
  '_ string (for example: 1 - 7 or 7+)
  vCounter = oSiebApplet.RecordCounter
 
  Do
    If InStr(1, vCounter, "+") <> 0 Then
      oSiebApplet.SiebList("uiname:=" & pValUINameSiebList).NextRowSet
      vCounter = oSiebApplet.RecordCounter
    Else
      vCounter = oSiebApplet.RecordCounter
      Exit Do
    End If
  Loop
 
  If InStr(1, vCounter, "of") <> 0 Then
    vCounter = CInt(Trim(Split(CStr(vCounter), "of")(1)))
  End If
 
  GetSiebListRows = vCounter
End Function
 
'* Usage:
' Dim oSiebApplet, intRows
' Set oSiebApplet = SiebApplication("").SiebScreen("").SiebView("").SiebApplet("")
'
' intRows = GetSiebListRows(oSiebApplet, "uiname:=mySiebList")

As I mentioned above, SiebList is quite a complex object. Suppose you have to find some text in one of the columns of the SiebList. Considering the workaround above to find the correct number of rows for the object, we can loop over all the rows until we find the value that we’re looking for.

Note that the column name may be different as it appears to the human eye. You will have to find the correct column name for this to work correctly. For example, in our environment, we have a column named ‘Application Number’. However, ‘Application Number’ is what appears to us, but in reality, QuickTest identifies that column by ‘Application ID’. So, please be a little careful when working with column headings in SiebList.

Finding a text string in a SiebList column

'—————————————————————————————————————————
' Name: Function SiebListFindValRow
' 
' Purpose: Find a row from a column in which a given value (sVal) is located
' 
' Input:
'  oSiebApplet - object reference to the SiebApplet hierarchy
'  pValUINameSiebList - uiname property's value for the SiebList object
'  sColumnName - name of the column where the value is to be found
'  sVal - value that is to be found
' 
' Output: 
'  Integer
' 
'Dependancy: 
'  SiebListRows
' 
' Date:
' 
' Author: 
' 
' Remarks: Make sure the columns name is correct - sometimes the header name
' is not the actual name.
'—————————————————————————————————————————
Function SiebListFindValRow( byRef oSiebApplet, pValUINameSiebList, sColumnName, sVal )
'—————————————————————————————————————————
  'SiebList is a list object in a Siebel test automation environment

  Dim iRows, r, sData, sMsg
 
  If InStr(1, pValUINameSiebList, "uiname") <> 0 Then
    pValUINameSiebList = Trim(Split(pValUINameSiebList, ":=")(1))
  End If
 
  '* Uses GetSiebListRows
  iRows = GetSiebListRows( oSiebApplet, pValUINameSiebList )
 
  oSiebApplet.SiebList("uiname:=" & pValUINameSiebList).FirstRowSet
 
  For r = 0 to iRows - 1
 
    oSiebApplet.SiebList("uiname:=" & pValUINameSiebList).ActivateRow r
    sData = Trim(oSiebApplet.SiebList("uiname:=" & pValUINameSiebList)_
          .GetCellText(sColumnName, r))
 
    If sData = sVal Then
      SiebListFindValRow = r
      sMsg = "The following string: [" & sVal & "] was found in the " & _
            sColumnName & " column of the Siebel List"
      Reporter.ReportEvent micDone, "Siebel List Value found", sMsg
      Exit Function
    End If
 
  Next
 
End Function
 
'* Usage:
' Dim oSiebApplet, intRow
' Set oSiebApplet = SiebApplication("").SiebScreen("").SiebView("").SiebApplet("")
'
' intRow = SiebListFindValRow(oSiebApplet, "uiname:=mySiebList", "Application ID", "Text")

Finding all rows in a column where a text string is found
Now, similar to the requirement above, we may have to find all the rows that carry the text we’re looking for. This can be from 1 to 2 or more rows. This method returns a collection object:

'—————————————————————————————————————————
' Name: Function SiebListFindValAllRows
' 
' Purpose: Find all rows from a given column where a given value exists
' 
' Input:
'  oSiebApplet - object reference to the SiebApplet hierarchy
'  pValUINameSiebList - uiname property's value for the SiebList object
'  sColumnName - name of the column where the value is to be found
'  sVal - value that is to be found
' 
' Output: 
'  Object
' 
'Dependancy: 
'  SiebListRows
' 
' Date:
' 
' Author: 
' 
' Remarks: Make sure the columns name is correct - sometimes the header name is not the actual name.
'—————————————————————————————————————————
Function SiebListFindValAllRows( byRef oSiebApplet, pValUINameSiebList, sColumnName, sVal )
'—————————————————————————————————————————
  'SiebList is a list object in a Siebel test automation environment
  
  Dim iRowsTotal, iRowsRef
  Dim r, i, n, sData, arrArray
 
  Dim oDict: Set oDict = CreateObject( "Scripting.Dictionary" )
 
  If InStr(1, pValUINameSiebList, "uiname") <> 0 Then
    pValUINameSiebList = Trim(Split(pValUINameSiebList, ":=")(1))
  End If
 
  n = 0
 
  'Calls the method: GetSiebListRows (see method above)
  iRowsTotal = GetSiebListRows( oSiebApplet, pValUINameSiebList )
  iRowsRef = CInt(oSiebApplet.SiebList("uiname:=" & pValUINameSiebList).RowsCount)
 
  oSiebApplet.SiebList("uiname:=" & pValUINameSiebList).FirstRowSet
 
  For r = 0 to iRowsTotal - 1
    i = r
    If iRowsRef <= r + 1 Then
      i = iRowsRef - 1
    End If
 
    sData = Trim(oSiebApplet.SiebList("uiname:=" & pValUINameSiebList).GetCellText(sColumnName, i))
 
    If sData = sVal Then
      oDict.Add n+1, r
      n = n + 1
    End If
 
    oSiebApplet.SiebList("uiname:=" & pValUINameSiebList).NextRow
  Next
 
  Set SiebListFindValAllRows = oDict
 
End Function
 
'* Usage:
' Dim oSiebApplet, RowCollection
' Set oSiebApplet = SiebApplication("").SiebScreen("").SiebView("").SiebApplet("")
'
' Set RowCollection = SiebListFindValRow(oSiebApplet, "uiname:=mySiebList", "Application ID", "Text")

Download this code

References

  1. Functional Test Automation Objects for High Interactivity Siebel Applications
  2. AdvancedQTP Forums

If you have any questions, please ask them in the comments section. If your query is confidential, please use the Contact Form to send me an e-mail instead.

{ 3 comments… read them below or add one }

1 suni February 19, 2010 at 5:43 am

Hi Anshoo,

Hope You are doing good.We are doing the usibility testing on Sibel 8.1.

The first function worked fine on siebel 8.1 where as the function that we developed on getting the count of all rows failed on siebel 7.7 as the record counter is different in both the versions.

The second function works fine if the value is with in the visible rows and throws error if the value is not with in the visible rows i mean it is not looping thru the next row set.I had to put one counter and click on next row set accordingly.I just want to confirm whether the version which u worked on scroll thru all the rows when activated

Cheers
Suni

Reply

2 Anshoo Arora February 19, 2010 at 9:38 am

Hi Suni,

I also had this issue and I had written a new version of the function, which I can’t remember where I had saved. Another reader had used it and found some issues with Siebel 7.8. I had sent her the solution but forgot to update this thread. I will try to find it soon.

Thanks :)

I just want to confirm whether the version which u worked on scroll thru all the rows when activated

As the RecordCounter increases, the rows start to scroll. I think there is also another way to find the rowCount quickly without following this process, which is quite long. I hope I had access to Siebel so I could check it for you..

3 Anshoo Arora March 20, 2010 at 12:26 am

Hi Suni,

A new article for version 8.1 will be available on Monday :)

Leave a Comment

{ 1 trackback }

Previous post:

Next post: