Forum Discussion
Why do you not want to use NameMapping? This is the primary and preferred/best practice method for object identification in TestComplete. It abstracts the UI object identification from your code so that you can alter your object identification without needing to affect your code (that's the beauty of Aliases). You are using TestComplete, not UFT... So, you may need to adapt your automation techniques to the tool.
TestComplete does not allow you to over-ride/overload/replace the "Click" methods with your own... you still need to work with TestComplete's "Click".
If you WANT to construct your own object identification layer in code, you will want to use liberally the FindChild, FindAllChildren, FindChildEx, etc., methods... but they require you to start with The basics of the AUT... Sys.Process('myapp') or Sys.Browser(<browsername>)... but you're going to lose performance... Finding objects and using any code techniques to construct and recognize objects in code is going to SEVERELY slow your test cases because you will need to search for the object EVERY time... while NameMapping caches much of the information and is internal code logic of the Tool rather than "interpreted" script code... it natively runs faster.
So.... back to question 1: Why do you want to avoid using NameMapping when, for the tool you have selected to use, it is the best practice for the tool?
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
- AlexKaras8 years agoCommunity Hero
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 SubNote, 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.
- shankar_r8 years agoCommunity Hero
Based on your explanation, Does all your objects has unique name or property in-order to use only one parameter make your object to identify? I don't think any AUT has this.
Why we want to go to NameMapping?
- It makes maintenance easy
- It has best functions like Extended Find, Conditional Object Mapping, Using different type of property values which can set thru run time, etc. which reduces your complexity of object mapping.
- Aliases make your name mapping to be uch understandable and easy to update.
- TestComplete making good enhancements on NameMapping which increases our code to execute effortless
I know, Since you are from UFT background you want to accomplish your requirements in UFT way in TestComplete which makes you lot of confusions and questions.
As you are now working with TestComplete[i hope] you may want to spent some time on the TestComplete 's powerful modules like Project Variables, NameMapping and lot of in-built functions which increases os Automation code more descriptive.