Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Finding WebElements
#1
Solved: 11 Years, 3 Months, 2 Weeks ago
I am trying to get the WebElement of a WebTable that has 7 columns. I need the page numbher found in the 5th column.My code below returns no data. I can not figure why.

Any thoughts?

Code:
Set TableObj = Browser("Wisdom").Page("Wisdom IA_2").Frame("parent").WebTable("Select All")

rNumber = 1
RowCount = TableObj.RowCount

For r = 1 to RowCount
    If r <> 2 Then
            ColCount = TableObj.ColumnCount(r )
           For c = 1 to ColCount
               'msgbox ColCount
                    ChildCountPage = TableObj.ChildItemCount(r, c, "WebElement")
                    'msgbox ChildCountPage
                     If ChildCountPage >  0 Then
                            For k = 0 to ChildCountPage - 1
                                        rNumber = rNumber +1
                                        Set WebObj = TableObj.ChildItem(r, c, "WebElement", k)
                                        NumPages = WebObj.GetROProperty("innertext")

                                        If c = 5 Then
                                      'Retrieve the column index
                                        objExcel.Cells(rNumber, 6).Value = NumPages
                                         End If
                                                

                            Next
                    End If
          Next
    End If
Next
Reply
#2
Solved: 11 Years, 3 Months, 2 Weeks ago
Hello Lorena,

Just did some little changes in your script. When you know that you want the data of 5th column then no need to put an extra for loop for column

Code:
Set TableObj = Browser("Wisdom").Page("Wisdom IA_2").Frame("parent").WebTable("Select All")

RowCount= TableObj.RowCount

rNumber = 1

For r = 1 to RowCount
    If r <> 2 Then
        ChildCountPage=TableObj.ChildItemCount(r, 5, "WebElement")
        If ChildCountPage > 0 Then
                For k = 0 to ChildCountPage - 1 ' no need to run the index loop also as you can debug on which index number the pages are coming and provide that index no in childitem method
                    rNumber = rNumber +1
                    NumPages = TableObj.ChildItem(r,5, "WebElement", k).GetROProperty("innertext")
                     If NumPages<>"" Then
                        objExcel.Cells(rNumber, 6).Value = NumPages
                        Exit For
                     End If
                Next
        End If
      End If
Next

Regards,
Parminder
Reply
#3
Solved: 11 Years, 3 Months, 2 Weeks ago
Parminder,

Thx for your help.

With regards to your statement " no need to run the index loop also as you can debug on which index number the pages are coming and provide that index no in childitem method",

I was trying to find all of the columns with WebElement to see if I find any of them. See screenshot. My GetROProperty does not seem to be able to dig down far enough to find the WebElements within the table. My code brings back the WebElements of the Links (that I do not want) but not of the objects that class are WebElements

I tried your suggested code, but I rerceive a Run Error:
Unspecified error
Line (41): "ChildCountPage=TableObj.ChildItemCount(r, 5, "WebElement")".

I also added screenshots of the OR of the webelements and vtable output.

Thx again for your help.


Attached Files
.pdf   Find page number.pdf (Size: 85.22 KB / Downloads: 156)
.pdf   OR for WebElement.pdf (Size: 61.04 KB / Downloads: 178)
.pdf   output table.pdf (Size: 83.76 KB / Downloads: 133)
Reply
#4
Solved: 11 Years, 3 Months, 2 Weeks ago
Hello Lorena,

If i understand right, then you need the data displayed in the Pages column.

Please use the below code:

Code:
Set TableObj = Browser("Wisdom").Page("Wisdom IA_2").Frame("parent").WebTable("Select All")

RowCount= TableObj.RowCount

rNumber = 1

For r = 3 to RowCount
rNumber = rNumber +1
NumPages = TableObj.GetCellData(r,5)
objExcel.Cells(rNumber, 6).Value = NumPages
Next


If still your problem is not solved then i will need the OR screenshot of webtable(Select All) with column and rows displayed.

Regards,
Parminder
Reply
#5
Solved: 11 Years, 3 Months, 2 Weeks ago
Parminder,

Wow! this works great. I was making a much bigger todo for nothing.

I am curious why the code I do have wont dig down to find the WebElements of the columns (Account No, Receive Date, Desfription).

I am receiving the following Run Error:

Object required: 'TableObj.ChildItem(...)'
Line (53): "NumPages = TableObj.ChildItem(r,5, "WebElement", k).GetROProperty("innertext")".

I changed the ...(r, 5,.... to ...(r, c,.... to grab all of the page WebElements. The Run Aerror goes away but the data returned to the table only consists of thev DocType and Action columns. I must be pointing to the wrong table.

Attached oin my previous chast is a screenshot of the OR.


My code:

Code:
Set TableObj = Browser("Wisdom").Page("Wisdom IA_2").Frame("parent").WebTable("Select All")
RowCount= TableObj.RowCount

rNumber = 1
NumPages = 0
'-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Code:
For r = 1 to RowCount
    If r <> 2 Then
            ColCount = TableObj.ColumnCount(r)
           For c = 1 to ColCount
               'msgbox ColCount
                    ChildCountPage = TableObj.ChildItemCount(r, c, "WebElement")
                    'msgbox ChildCountPage
                     If ChildCountPage >  0 Then
                            For k = 0 to ChildCountPage - 1
                                    rNumber = rNumber +1
            
                                    NumPages = TableObj.ChildItem(r,5, "WebElement", k).GetROProperty("innertext")
                                        Num = c
                                        If Num <> “” Then
                                              'Retrieve the column index
                                                objExcel.Cells(rNumber, 6).Value = NumPages
                                        'End If        
                            Next
                    End If
          Next
    End If
Next




thx my friend ;-)
Reply
#6
Solved: 11 Years, 3 Months, 2 Weeks ago
Hi Lorena,

I cannot say why your code is not working as I dont have the application with me. But if you want to get all the items of the webtable then you can use below code:

Code:
Set TableObj = Browser("Wisdom").Page("Wisdom IA_2").Frame("parent").WebTable("Select All")

RowCount= TableObj.RowCount
Cols=TableObj.ColumnCount
rNumber = 1

For r = 3 to RowCount
            For i=1 to  Cols
                        rNumber = rNumber +1
                        NumPages = TableObj.GetCellData(r,i)
                        objExcel.Cells(rNumber, 6).Value = NumPages
            Next
Next

Always use GetCellData if you want the data from any webtable cell. Use ChildItem method when one cell of webtable contains more than one value and you need index to get the desired value from that cell e.g.
the last column of you webtable which contains 3 links, If you want to click any of these three links then you have to use childitem method.

Regards,
Parminder
Reply
#7
Solved: 11 Years, 3 Months, 2 Weeks ago
Parminder

Thx for the clarification. By this I know understand why my code did not grab what I thought it would.

A super big thxxxx

Reply
#8
Solved: 11 Years, 3 Months, 2 Weeks ago
Lorena,

Its my pleasure if i could help you through this forum as it has helped me solve some of my problems. But you are welcome to ask anything you face problem with Smile. Just let others also know about this forum to grow the forum and enrich the knowledge of others.

Have a great day..

Regards,
Parminder
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Get numbers inside all webelements in webtable and sort them pradeep537 1 2,794 08-04-2016, 01:24 AM
Last Post: Ankur
  Comparing webtable data with weblist and webelements in other webpage arnav 1 5,795 04-18-2014, 10:01 PM
Last Post: Parke
Exclamation UFT is not finding object in runtime but able to locate the object from repository amar.vallapreddy 1 2,720 02-25-2014, 02:22 PM
Last Post: guin.anirban
  WebElements shayk1985 4 3,406 03-04-2013, 04:19 AM
Last Post: shayk1985
  How to remove space between webelements silpavinod 2 3,236 10-11-2012, 02:53 PM
Last Post: silpavinod

Forum Jump:


Users browsing this thread: 1 Guest(s)