Forum Discussion
Thanks Robert for your reply.
In the NameMapping way of object identification,I can't use descriptive way of accessing the object. I will explain you why I need to have descriptive way of access is that I need to have subroutines which are generic and not tied up with NameMapping.
For Ex: I want to create customized Click Button subroutine,so that I can put some customized code like first checking the object exist or not and then add some reporting code.
In UFT, we used to this way sorry for going back to UFT, where we are aware that that we can access the property using descriptive programming and once we create this, we are not concerned about the object repository or in TestComplete case it is NameMapping.
Sub ClickButton(btName)
If Browser("name:=.*").Page("title:=.*").WebButton("name:"=btName).Exist() Then
Browser("name:=.*").Page("title:=.*").WebButton("name:"=btName).Click
End If
End Sub
In the above code, I need just pass the button name and that's it, this will work on any web page or button, so it is application independent and more useful in organizing subroutines or function.
Regards,
Nimish
Hi Nimish,
> Sub ClickButton(btName)
> If Browser("name:=.*").Page("title:=.*").WebButton("name:"=btName).Exist() Then
> Browser("name:=.*").Page("title:=.*").WebButton("name:"=btName).Click
> End If
> End Sub
The exact port of the above code to TestComplete is:
Sub ClickButton(btName) Dim btn Set btn = Sys.Browser("*").FindChild(Array("ObjectType", "ObjectIdentifier"), Array("Button", btName), 1000) If (btn.Exist) Then Call btn.Click() End If End Sub
Note, however, that this code (like yours from UFT):
a) Assumes that there is only one browser process in the system with only one web page opened;
b) All buttons on all tested web pages are defined the same way in the markup;
c) As it was already mentioned by others, the code obviously has less than optimal performance.
The final decision is up to you depending on your actual needs and expectations.
P.S.
> In the NameMapping way of object identification,I can't use descriptive way of accessing the object.
Actually, you can: define your browser as any browser in the system and the page like any page in the system and the button as a child of the page with the Extended Find option enabled and you will get exactly the same as in UFT or the code above. Obviously, with exactly the same problems and inconveniences.