Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get the ClassName of the cell object from a Table.
#1
Not Solved
I want to get the Class Name of the cell Object from a table. Mean to say i want to return the class name whether it's a checkbox, editbox, list, button etc.
Reply
#2
Not Solved
Hi
1st Approach:
Use 'ChildItem' method to get the class.
Code:
Set WebEditObj = Browser("Browser").Page("Page").WebTable("Sortable table").ChildItem(Row,Column,"WebEdit",0)



2nd Approach:
Use 'GetROProperty'.

Code:
strClassName = Browser("Browser").Page("Page").WebTable("Table").GetROProperty("Class")


~Regards
Reply
#3
Not Solved
Thanks for your answer.

But i want to return the class of the cell object. In your 1st example you are clearly mentioned class as "WebEdit' and in the 2nd example will return "Table".
Reply
#4
Not Solved
Hi,

Actually "micclass" is the must entered property for "childobject" approch.And for the GetROproperty method it's mandatory to define the ClassType.

Normally we get the other property with the help of ClassType.So this case seems little strange.

May you please be more specific to your requirement?
Reply
#5
Not Solved
The requirement is like i want to write a function for table that will return the Class Name of the particular cell if i pass the row and column number. Obviously if and only if that Class to that particular cell exists.
Reply
#6
Not Solved
Hi Saket,

can you please help me on this query?
Reply
#7
Not Solved
Hi All,

Is there any update on my query?
Reply
#8
Not Solved
Hi anirban,

Are you able to get the data of each cell using "GetCellData" method in this case???
Reply
#9
Not Solved
I think we are getting confused whether you want the micclass (QTP object type), the CSS class (the value of the element's class attribute), or the input type (the value of an input element's type attribute). Here is code to check each cell of a table and return several types of information about the first child of each cell. I assume you could customize it if you needed to check all the cell children and that you can remove the parts you aren't interested in. This code was tested with the attached HTML file (see attachment) after adding the table to the Object Repository and renaming it "Table". I do not think this code will work for nested tables, so beware. The reason is that the ChildObjects function returns child objects for any hierarchy so it would potentially return rows and columns nested inside the parent table if there are any, so again beware.

Quote:Set rowDesc = Description.Create
rowDesc("micclass").Value = "WebElement"
rowDesc("html tag").Value = "TR"

Set cellDesc = Description.Create
cellDesc("micclass").Value = "WebElement"
cellDesc("html tag").Value = "TD"

Set rows = Browser("Test").Page("Test").WebTable("Table").ChildObjects(rowDesc)

For i = 0 To rows.Count - 1

_____Dim cells: Set cells = rows.Item(i).ChildObjects(cellDesc)

_____For j = 0 To cells.Count - 1

__________Dim message: message = "Checking row " & i+1 & ", column " & j+1

__________Dim cellChildren: Set cellChildren = cells.Item(j).ChildObjects()

__________If cellChildren.Count > 0 Then

_______________Dim firstChild: Set firstChild = cells.Item(j).ChildObjects().Item(0)

_______________message = message & vbNewLine & vbNewLine & "Found " & cellChildren.Count & _
______________________________" child object(s). First child:" & vbNewLine & vbNewLine & _
______________________________"micclass: '" & firstChild.GetROProperty("micclass") & "'" & vbNewLine

_______________If firstChild.GetROProperty("html tag") = "INPUT" Then
____________________message = message & "input type: '" & firstChild.GetROProperty("type") & "'" & vbNewLine
_______________End If

_______________message = message & "css class: '" & firstChild.GetROProperty("class") & "'"

__________Else

_______________message = message & vbNewLine & vbNewLine & "Found no cell child objects. Cell text:" & vbNewLine & vbNewLine & _
______________________________"'" & cells.Item(j).GetROProperty("innertext") & "'"

__________End If

__________MsgBox message

_____Next

Next


Attached Files
.html   Test.html (Size: 1.62 KB / Downloads: 116)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)