Micro Focus QTP (UFT) Forums
QTP Unable to differentiate WebTable in Application - Solved - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: QTP Unable to differentiate WebTable in Application - Solved (/Thread-QTP-Unable-to-differentiate-WebTable-in-Application-Solved)



QTP Unable to differentiate WebTable in Application - Solved - EnthusiasticLearner - 12-25-2013

I am working on an application where there are two different web tables displayed.

The second web table is detail description of the first web table so it displays when we select a row in the first web table. In other words, Each row in the first table is selectable and when selected corresponds to the second web table

The problem now I am facing is retrieving data from second web table for different entity of first one since all the property of the web table are similar expect the below property

"html ID" which corresponds to - "DetailParty_randomno"

This random number is the one which defines the uniqueness of the second web table, which can be retrieved from the first web table though it isn't found in the properties section when we use the Object spy. I can see this random number when I view the source code of the page. It's displayed as value entity in the tr tag

Value entity looks like "Party_randomno"

My question is if there a way to retrieve this value for each row and then use it in identifying the second web table?

However I did try to read from second table by hard coding "html id" in webtable property to see if it's being read but it didn't work So my second question is with respect to the correctness of the below descriptive programming code. Is there something else I need to include/exclude in the WebTable property to find uniqueness.

I also did my research and found that it's useful to use index but I am not aware on how to find the index of a web table? That explanation would also help me in my learning

Code:
Set ObjTable = Browser("name :=" &BrowserPage).Page("name := " & BrowserPage).WebTable("class:= Web_Table", "class name:= WebTable" , "html id:= DetailParty_7")


Update

I found a solution for one of my two problems in an another forum

1. Getting the Value Id - Solved
2. Parsing it to WT2 to uniquely identify it

For the first problem below is the solution. However my descriptive programming(first and last line) in the below is not working. Can you help me correct it?

Code:
BrowserPage = Browser("micClass:=Browser").GetROProperty("name")
Set desc = Description.Create()
desc("html tag").Value = "tr"
Set Rows = Browser("B").Page("P").Webtable("WT").ChildObjects(desc)
RoCounter = Rows.Count-1
For valuecount = 0 To RoCounter
    id=  rows(i).Object.GetAttribute("value")
Next
'When the right ID is got, parsing it in the below for WT2 Identification Id would be Party_1, Party_3 and so on. However for web table 2 html id needs to have "Detail" word in front of it
Set ObjTable = Browser("name :=" &BrowserPage).Page("name := " & BrowserPage).WebTable("class:= Web_Table", "html id:= Detail" &id)

Thanks in Advance


RE: QTP Unable to differentiate WebTable in Application as all of them have same property - basanth27 - 12-26-2013

Dear EnthustiaticLearner,
Thank you very much for the detailed explanation. My 2 cents would be to go with the index rather than pondering over an unique id. Index in itself is a problem solver in dynamic webtables as well as chained tables.

Index starts from Zero, so it is going to be a bit of trial and error before you arrive at the right one. Also, check the Spy to see what the index says? If it is has the right value you may use it. You can also record the object and check the index identification on the Object Repository.

Code:
Set ObjTable = Browser("name :=" &BrowserPage).Page("name := " & BrowserPage).WebTable("class:= Web_Table", "class name:= WebTable" , "index:=0")



Reply to Basanth - EnthusiasticLearner - 12-27-2013

Thank you Basanth for your input. I do get the Index value as an Ordinal Identifier but the index value changes for each entity/user I am searching so I need to find the index during the run time before using it(Sorry about the bold item been dropped in my first post)

And just to be more elaborate on my previous post, this is how my source look like for a row in Web Table 1 with respect to tr tag

Code:
<tr style="background-color:yellow" value="Party_1" onclick="Call peoplehighlight(&quot;Party_1&quot;)" language="vbscript">

And an example for my Web Table 1 and 2 to get a detailed picture of what I am trying to say(I am sure you understood my first post, this is for people who are trying to help me and are not able to picture my first post) -

As an example The Page talks about details of a family for a person being searched

I search the user Enthusiastic Learner and navigate to the questioned page

Web table 1 contains something like below

____________________________________________
RelationShip | Name
____________________________________________
Father | AAA
____________________________________________
Mother | BBB
____________________________________________
Brother | CCC
____________________________________________
Sister | DDD
____________________________________________
Sister2 | EEE
____________________________________________


Web Table 2 Contains detailed information for each row in Web Table 1 as I earlier mentioned. First row Relationship is not selectable
____________________________________________
Details
____________________________________________
Name | AAA
____________________________________________
Age | 50
____________________________________________
Relationship | Father
____________________________________________
and so on


RE: QTP Unable to differentiate WebTable in Application as all of them have same property - EnthusiasticLearner - 12-27-2013

This has been solved. There are some syntax error in my descriptive program such as spaces as evident in my first post.

For getting value from source code, you can use the similar code seen in my first post, ignoring the first and last line