Showing posts with label Webtable. Show all posts
Showing posts with label Webtable. Show all posts

Tuesday, March 30, 2010

Do You Want To View Your Web Table's Structure?

Do you want to view your web table's structure? If the answer is Yes, then try the below snippet.
Set objTable=Browser("name:=Google").Page("title:=Google").WebTable("name:=q").Object
strTRCount=objTable.getElementsByTagName("TD").Length-1
For i=0 to strTRCount
objTable.getElementsByTagName("TD")(i).style.borderstyle="solid"
objTable.getElementsByTagName("TD")(i).style.borderwidth="2px"
objTable.getElementsByTagName("TD")(i).style.bordercolor="#98bf21"
Next
Try the above code with Google page, you will get the output as below.

Now, you are able to view all the cells of the webtable.

Friday, March 12, 2010

Working with ChildItem and ChildItemCount methods

Consider a webtable has one row and two columns and the second column contains a webedit.
If you run the below code, Exist method will be passed and the value will be set into webedit.

If obj.ChildItem(1,2,"WebEdit",0).Exist(0) Then
obj.ChildItem(1,2,"WebEdit",0).Set "QTP"
End If
Suppose, if you run the code for negative condition (I.e. You are going to look for webedit in the first column where it does not exist), you will get an error as same as below.
To avoid this problem, use ChildItemCount method instead of ChildItem for the above criteria.

If obj.ChildItemCount(1,1,"WebEdit")>0 Then
obj.ChildItem(1,1,"WebEdit",0).Set "QTP"
End If
Now, you do not get the error for negative case.