Micro Focus QTP (UFT) Forums
Web Table - 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 Interview Questions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Interview-Questions)
+--- Thread: Web Table (/Thread-Web-Table--7895)



Web Table - debakanta - 02-15-2014

Hi,
Today i have faced one interview question.
Q:In a web Table some of the cell contains same cell data.how to find out number of similar data & how many cell contains this same data.
Example:Suppose 5 cell contains the data "X".How to find how many "X" are there & how many cell contains this.
x a b c
d e f x
z x x y
v b x m

Ans:


RE: Web Table - supputuri - 02-17-2014

you can use descriptive program and get the childobjects (TR with innertext 'x') and then use the use your own logic to get the number of x in the row.
Simple logic:
Code:
NumberOfX= Len(childItem(i))-Len(Replace(childItem(i),"x",""))



RE: Web Table - anu05446 - 02-18-2014

hi, can you please explain your approach, I am not sure how you mean to go about it. say in the webtable, each cell is a webelement, we need to count no, of cells which have values as "X", ie innertext for the webelement is "x", in this case , I don't think ChildObject can be used as the webelement, thou contained in the webtable, is a child of the page and not the webtable. correct me if I'm wrong.


RE: Web Table - supputuri - 02-19-2014

Check out this below snippet
Code:
'********************************************
''My Search Item
sSearchItem = "s" 'Change this based on your interest
'*********************************************

Set oGetAlp = Description.Create()
oGetAlp("html tag").value = "TR"
oGetAlp("innertext").Value =  ".*" & sSearchItem &".*"

Set oRows = Browser("QTP Forums - Search Results").Page("QTP Forums - Search Results").WebTable("Search Results").ChildObjects(oGetAlp)
Set oGetColAlp = Description.Create()
oGetColAlp("html tag").value = "TD"
oGetColAlp("innertext").Value = ".*" & sSearchItem &".*"
iRows = oRows.Count

For i = 0 to oRows.Count-1
    'msgbox oRows(i).GetROProperty("innertext")
    Set oTD = oRows(i).ChildObjectS(oGetColAlp)
    For j = 0 to oTD.Count-1
        sTDValue = oTD(j).GetROProperty("innertext")
        NumOccurances = NumOccurances+(len(sTDValue)-Len(Replace(sTDValue,sSearchItem,"")))
    Next
    iCols = iCols+ oTD.Count
Next

print "Total Number of Rows with " & sSearchItem &  ": "& iRows
print "Total Number of Columns  with  " & sSearchItem &  ": " & iCols
Print "Total Number of Occurances of  " & sSearchItem & ": " &  NumOccurances
Let me know if you have any queries on this


RE: Web Table - anu05446 - 02-26-2014

got it ..thanks Smile


RE: Web Table - supputuri - 02-26-2014

no problem ... welcome buddy


RE: Web Table-----------Pls clarify - AMIT35352 - 06-15-2015

Code:
oGetAlp("innertext").Value =  ".*" & sSearchItem &".*"


Query:-


What is ".*" used for?What it does?

Thanks in Advance