Search This Blog

Friday, September 9, 2011

QTP & QC ->Code for to get the required row number for the specified text as serach string

'**********************************************************************************************************
'Function Name:   fun_Acx_GetRowWithText(strRequiredText , intColumn)
'Description :        Used to get the required row number for the specified text as serach string
'Parameters:        strRequiredText , intColumn
                          int Column : need to enter the column number, in which column you are searching to get the row number of particular text
                          strRequiredText: Need to give the text
'Return  value       integer
'Registerd To      AcxTable
'Example:             fun_Acx_GetRowWithText("322" , 2)
'**********************************************************************************************************
Function fun_Acx_GetRowWithText(test_object,strRequiredText , intColumn)
 Dim intRowCount,i
 fun_Acx_GetRowWithText = ""
 intRowCount = test_object.RowCount
 For i = 2 to intRowCount
  If Trim(test_object.GetCellData(i,intColumn)) = Trim(strRequiredText) Then
   fun_Acx_GetRowWithText = i
   Exit For
  End If
 Next
End Function

RegisterUserFunc "AcxTable", "fun_Acx_GetRowWithText", "fun_Acx_GetRowWithText"

Same function can be used for webtable also. but need to create an object for the webtable

Example Code:-

Set objGrid = Browser("Browser Main").Page("Allocation Review").AcxTable("FarPoint Spread 6.0")

intChainTotalRowNumber = Browser("Browser Main").Page("Allocation Review").AcxTable("FarPoint Spread 6.0").fun_Acx_GetRowWithText("(+) Chain Total", intStoreColumnNumber)

No comments:

Post a Comment