Micro Focus QTP (UFT) Forums
Compare Webelement with Datatable Values - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Compare Webelement with Datatable Values (/Thread-Compare-Webelement-with-Datatable-Values)



Compare Webelement with Datatable Values - hamzaz - 04-27-2012

Hi All,

I need to compare the value of WebElement which i feteched at run time using GetRoProperty("innertext"). Now i need to compare this value with all the values that i had in my datatable one by one and if i found the value then i have to see at which row the value exists. Please let me know how to do this.




RE: Compare Webelement with Datatable Values - srikanthqtp - 04-29-2012

Hi

Using the below code you can fetch the webelemt innertext runtime at the same time you can compare that value in ur datatable which is avaiable in ur Global sheet

Code:
strSrch = Browser().Page().Frame().webelement("innertext")
strFound = False
RCnt =Datatable.GetRowCount
CCnt =  Datatable.GetSheet("Global").GetParameterCount
For iR = 1 to RCnt
  For iC =1 to CCnt
    Datatable.SetCurrentRow(iR)
    strval= Datatable.Value(iC)
    If strcomp(strSrch,strval,1)=0 Then
      Msgbox "Search String Found in## " &iR & "##Row"
      strFound = True
      Exit For             
    End If
Next
If strFound = True Then
   Exit For
End If
Next