Search This Blog

Friday, September 9, 2011

QTP & QC : Code for function to get the required row number for the specified text matches partially as serach string in particular column

**********************************************************************************************************
'Function Name:   fun_Ex_Acx_GetRowWithText(strRequiredText, intColumn)
'Description :        Used to get the required row number for the specified text  matches partially as serach string
'Author          :    Naresh Gupta . D
'Parameters:        strRequiredText , intColumn
'Return  value       integer
'Registerd To      AcxTable
'Base Project      EFAS
'Example:              fun_Ex_Acx_GetRowWithText("Haslet" , 1)
'**********************************************************************************************************
Function fun_Ex_Acx_GetRowWithText(test_Object, strRequiredText, intColumn)
 Dim intRowCount,i
 fun_Ex_Acx_GetRowWithText = ""
 intRowCount = test_object.RowCount
 For i = 1 to intRowCount
  If Instr(Trim(test_Object.GetCellData(i, intColumn)), Trim(strRequiredText)) Then
   fun_Ex_Acx_GetRowWithText = i
   Exit For
  End If
 Next
End Function
RegisterUserFunc "AcxTable", "fun_Ex_Acx_GetRowWithText", "fun_Ex_Acx_GetRowWithText"

we can use the same function to get the row number in a webtable of a particular column
but need to create a 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