Showing posts with label Webedit. Show all posts
Showing posts with label Webedit. Show all posts

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.