Hello,
I know, In Test Complete there no need to create objectRepository we can use Name Mapping in place of object repository.
but i have to create ObjectRepository, How can i call my objects
Like:
Unit A
Function AllObjects()
Set abc = ........Something here.......
Set bcd = ........Something here.......
Set cde = ........Something here.......
End Function
'USEUNIT A
Sub TestCase()
'here what should i do so that I can get objects
as i am trying A.Allobjects.
but after Allobjects proposals does'nt show objects in the function
how can i call the objects declared in another unit, function.
End Sub
Solved! Go to Solution.
Thanks for the suggestions, AlexKaras, Wamboo!
@kaiiii, also, it's worth taking the following TestComplete basics course:
https://academy.smartbear.com/store/575377-testcomplete-basics-web-testing
Even if the course is oriented for Web Testing, it contains a lot of great descriptions of TestComplete Platform's features.
If nothing helped, let us know.
Hi,
There's no need to call it something like A.Allobjects.
If you use the NameMapping repository and (as we see in the code) you store references to NameMapping objects in variables.
You already have a reference, so you have to call AllObjects -> check the result and use the returned value in the code.
I think You are using VB.
I am using JavaScript but the example will be simple and i think you can understand it.
example:
Unit A
Function AllObjects()
Set abc = ........Something here.......
Set bcd = ........Something here.......
Set cde = ........Something here.......
End Function
Here you try to save values (NameMapping repository values in variables). Return these values from the function and use it in the routine you want. In JS this is something like that.
function storeValues() { let variable = Aliases.obj.obj; return variable; }
to be honest You can always store single NameMapping value inside variable without declaring function above it.
example:
var mainMenuButton = Aliases.obj.obj2;
or declare a function inside the variable:
var mainMenuButton = function() { return alias.Find(propNames, propValues, depth, refresh); }
ofc, instead of Alias.obj you can always use Sys.
Is that helpful? Is that what you meant?
Hi @Wamboo,
Thanks for your reply
somehow, I am getting your point.
function storeValues() { let variable = Aliases.obj.obj; return variable; }
In the above the function we put the name mapped value and assign it into a variable and get return of that function.
but If i have a list of variable .. so I think there will need to create a lot of function and it will not make easy.
....I am trying but not getting your point properly as first I am facing problem that
1) How can i create a Name Mapping repository.. It's good to create manually or by script.. I want to handle by script
2) How can I Store (objects or variables) in that repository.. and as you suggest that use NameMapped value and assign value in a variable and then return of that function. In that condition for lot of objests I have to create lot of functions. It's pathetic
3) The last one is if every thing is ready .. then how I will call that object from repository to in my test cases unit.
Starting from the beginning, I had the impression from the previous message that you deliberately do not want to use NameMapping.
ad 1) NameMapping is created by adding an appropriate item in the Project menu and then using the "object spy" option you add the indicated items to the repository.
The repository elements can be accessed in a script via Alias.obj etc.
Adding objects to the Name Mapping repository
Automatically - By default, TestComplete adds objects to the Name Mapping repository when you are recording and editing tests. See Mapping Objects Automatically.
Manually - You can add objects to the Name Mapping repository from screen or from the Object Browser. See Mapping Objects Manually.
Tip: The easiest way to map multiple objects quickly is to record user actions over these objects. TestComplete will map all the objects with which you have interacted automatically.
ad 2) You don't have to store it in variables. You can use it directly from the NameMapping repository via Alias.obj etc.
My example is completely different and results from not understanding your entry properly.
ad 3) Use the Aliases.obj
Hi @Wamboo ,
Thanks buddy
Now I got it and able to understand.
but now facing another problem... below is the code that I am using
Aliases.browser.pageLogin192.Login_Email_Address
but when i am trying to check proerties of this .. it's displaying everything disable
Please check the screenshot for same
Hmmm, it's weird... maybe someone else has an idea?
Simple questuins, but it's worth checking:
1) Do you have a WebTesting TestComplete license?
2) Do you have WebTesting plug-ins enabled?
3) Have you tried to enable all steps from this article?
Hi,
Easiest stuff first:
> it's displaying everything disable
Object does not exist (.Exists property equals to False). Thus all other properties are not accessible because they do not exist either.
Now more complex things related to the terminology:
> How can i call my objects
No way. Point.
Objects can not be called. Object is a wrapping structure for the data and methods that process those data. Object must be defined first. I.e. it must be described what data will it contain and what code will process the data. Then the object instance must be instantiated. Instantiation allocates memory to keep data, assigns data to the allocated memory and sets pointers to the processing code. Then you may call the code that will process the data.
Summarizing: object cannot be called, but methods of object instance can be called.
Now your code:
Function AllObjects()
Set abc = ........Something here.......
Set bcd = ........Something here.......
Set cde = ........Something here.......
End Function
The code assigns values (actually - references to some objects) to the abc, bcd and cde variables. As those variables are local to the AllObjects() function, they (variables) are dismissed of on function exit and cannot be used to access the objects that they referenced. (Existence and accessibility of the referenced objects is a separate question and you should read about objects disposal of and memory management in VBScript additionally.)
In order to keep variables and make them accessible outside of the AllObjects() function, those variables must be declared as public. I.e.:
Public abc Public bcd Public cde Function AllObjects() Set abc = ........Something here....... Set bcd = ........Something here....... Set cde = ........Something here....... End Function
After that in another unit you will be able to do something like this:
'USEUNIT A Sub TestCase() Call AllObjects() Call abc.<SomeMethodProvidedByObjectReferencedBy_abc_Variable>() End Sub
Note, however, that this approach should not be used in real life for the most of objects of your tested application.
Two primary cases:
a) Global variables are risky because they are accessible from everywhere and may be occasionally assigned some other value in an absolutely different part of your test code and you will have a hard debugging time to resolve this;
b) Objects of the tested application are usually created and destroyed while the application functions. So it is not possible to store the reference to some tested object until this object is created. And the stored reference will be invalidated when the tested object is destroyed in the tested application.
For example: it is not possible to store the reference to the Order Form to the abc variable until the form is opened in the tested application. And when the form is closed, abc variable will reference invalid object that cannot be used. (There are a couple of additional details here but they are out of scope at the moment.)
So, the best approach with TestComplete is to either use the provided NameMapping with Aliases, or to have a set of functions that will search for the required object and return a reference to it (if it exists), but not to try to search for all objects of the tested application on test start and keep references in public variables. This just will not work.
Thanks for the suggestions, AlexKaras, Wamboo!
@kaiiii, also, it's worth taking the following TestComplete basics course:
https://academy.smartbear.com/store/575377-testcomplete-basics-web-testing
Even if the course is oriented for Web Testing, it contains a lot of great descriptions of TestComplete Platform's features.
If nothing helped, let us know.
Subject | Author | Latest Post |
---|---|---|