Unable to identify WebTable Object runtime

661 views
Skip to first unread message

Shantanu Joshi

unread,
Oct 25, 2013, 3:07:05 PM10/25/13
to mercu...@googlegroups.com
Hi All,

I am working on a automation script which makes use of Webtable.

I have come across following problems while handling this issue:
1. The Webtable has changing index value. The Webtable index value changes when any operation on the same page is done(e.g. inserting textbox vale, checking checkbox). So when I use the same WebTable Object stored in shared OR in any other script, QTP fails to identify the Webtable object as the index value changes.

2. Also, the WebTable has 2 columns and it does not have any titles for the columns. The first row values are taken as column names. As the row values are unpredictable as per environment and data created, we can not traverse through webtable.

3. I want to check a WebCheckBox against an instructor's name present in that WebTable. The WebTalbe has two columns. 1st one is of instructors name and 2nd one contains the webcheckboxes for respective instructor names.

4. The WebTable object changes as per environment. We dont want to add many objects per environment. We want to use a single WebTabel object stored in shared OR which can be used runtime on every environment.

I have tried using DP(Desc.programng) but as the Webtable properties are not distinctive, it cant be used.

Please provide suggestions n solutions for solving the problem

Your help is appreciated.

Regards,
Shantanu Joshi
Automation Engineer

Parke

unread,
Oct 28, 2013, 1:56:23 PM10/28/13
to mercu...@googlegroups.com

Shantanu:

Is this the only webtable with two columns?
Is this the only webtable with webcheckboxes?
 

Parke

 

Shantanu Joshi

unread,
Oct 28, 2013, 3:20:12 PM10/28/13
to mercu...@googlegroups.com
Hi Parke,

This a WebTable with 2 columns.
The 1st one contains name of the instructor and second one contains webcheckbox for the corresponding instructor.

e.g I am an instructor and I want check checkbox corresponding to my name. Lets say 'shantanu' value is present in column one 3rd row then I will check webcheckbox present in 3rd row 2nd column.

I hope this makes picture more clear.

Regards,
Shantanu

Lloy Lim

unread,
Oct 29, 2013, 4:57:56 AM10/29/13
to mercu...@googlegroups.com
Hi Shantanu,

I bet you can still use DP in this case. Loop thru the instructor name in the WebTable object and determine its index. This index must the same with the WebCheckbox index. 

If you want to get some more info, I'd like you to invite and visit my blogsite. www.smartechnofiles.com, and I would be glad to share you the solution. 

Cheers!

Akhalesh Yadav

unread,
Oct 29, 2013, 3:16:48 AM10/29/13
to mercu...@googlegroups.com
Hi Shantnu,
                 As per my observation you can use below mentioned code.
     function FindName(fName)
     set oName= description.create()
          oName("class").value="Webelement"
          oName("text").value=fName
          oName("index").value=0
     rCount=browser("").page("").webtable("").getrowcount
     cCount=browser("").page("").webtable("").getcolumncount
    For i=0 to rCount
       For j=0 to cCount
         if browser("").page("").webtable("").celldata(oName).exist then
           browser("").page("").webtable("").webcheckbox("","index:="&i).set ON
         end if
       next
   next


Thanks...
Akhalesh
           


--
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en
 
---
You received this message because you are subscribed to the Google Groups "QTP - HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mercuryqtp+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Akhalesh yadav
+919555717928
+919310680659

Parke

unread,
Oct 29, 2013, 10:01:06 AM10/29/13
to mercu...@googlegroups.com
Shantanu:
 
The reason I asked about number of rows and columns was to find a method to uniquely identify the table.
Below are three possibilities that I can see.  The URL has a table that I tested against.  Once you have the unique table,
you can use descriptive programming to continue the testing.

''// http://relevantcodes.com/get-rowcolumn-of-an-object-in-a-webtable/
browserName = "Get.*"
pageTitle = "Get.*"
numColumns = 5
Three possibilities:
1) Execute the code to find the names of all the tables.  Are the names of the other tables constant?  If the other names are constant, you can determine the required table name by elimination.
Set oDesc = description.Create
oDesc("micclass").Value = "WebTable"
Set FindTables = Browser("name:="&browserName).Page("title:="&browserName).childobjects(oDesc)
For i = 0 to FindTables.count - 1
 print FindTables(i).GetROProperty("name")
Next

2) If the unknown table is the only table with two columns, find the name by using childobjects and finding the table with two columns.
Set oDesc = description.Create
oDesc("micclass").Value = "WebTable"
Set FindTables = Browser("name:="&browserName).Page("title:="&browserName).childobjects(oDesc)
For i = 0 to FindTables.count - 1
 If FindTables(i).GetROProperty("cols") = numColumns  Then
  print FindTables(i).GetROProperty("name")
 End If
Next
 
3) If neither of the above methods work, find which table has two columns and in the second column there is a webcheckbox.  Look at "outerHTML" and/or "type".  The code below prints the "outerHTML" for all the webelements in the table(s) that have a maximum columns.
 
Set oDesc = description.Create
oDesc("micclass").Value = "WebTable"
Set oDesc_2 = description.Create
oDesc_2("micclass").Value = "WebElement"
Set FindTables = Browser("name:="&browserName).Page("title:="&browserName).childobjects(oDesc)
For i = 0 to FindTables.count - 1
 If FindTables(i).GetROProperty("cols") = numColumns  Then
  print FindTables(i).GetROProperty("name")
  Set FindWebElements = Browser("name:="&browserName).Page("title:="&browserName).WebTable("cols:="&numColumns).childObjects(oDesc_2)
  print "number of webelements = " & FindWebElements.count
  For j = 0 to FindWebElements.count - 1
   print FindWebElements.item(j).GetROProperty("outerHTML")
  Next
 End If
Next
 
hth,
 
Parke

Shantanu Joshi

unread,
Nov 2, 2013, 9:13:52 AM11/2/13
to mercu...@googlegroups.com
Hi All,

Thanks for the help.

The issue is solved using following code.

I used DP approach.

Set oName = Description.Create()
oName("micclass").Value = "WebTable"
oName("cols").Value = 2

Set FindTables = Browser("").Page("").ChildObjects(oName)

For i = 0 to FindTables.count -1
       Rowcount = FindTables(i).RowCount
       for j = 0 to RowCount -1
             str = FindTables(i).GetCellData(j,2)
             If strComp(Trim(str),"Shantanu") = 0 then
                 Set ObjWebCheckBox = FindTable(i).ChildItem(j,2,"webCheckBox", 0)
                 ObjWebCheckBox.Click
                 Flag = 1
             End If
             Exit For
       Next
    if Flag = 1 then
       Exit For
    end If
next

Thanks for the guidance provided.


Enjoy Automation
Shantanu             

Parke Kuntz

unread,
Nov 2, 2013, 7:49:36 PM11/2/13
to QTP - HP Quick Test Professional - Automated Software Testing
Shantanu:
 
Very nice.
 
 
Parke


--
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en
 
---
You received this message because you are subscribed to the Google Groups "QTP - HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mercuryqtp+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Parke
Reply all
Reply to author
Forward
0 new messages