cancel
Showing results for 
Search instead for 
Did you mean: 

Create Property on Test Object

SOLVED
Highlighted
Contributor

Create Property on Test Object

Is there a way to create a property on a test object?

Essentially I'm looking for a way to add properties to a test object at runtime.

 

Example:

test_object = Aliases.Object

test_object.some_property = 'some important text'

or

AddProperty(test_object, some_property, 'some important text')

 

All I can find in the help files are references to the Object Driven Testing (ODT) stuff which is deprecated.

 

Any help would be appreciated.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Create Property on Test Object

TestComplete adds them... but as part of the object identification engine built into TestComplete and not in any way accessible to the user.  So, generally, no... you cannot alter the property or method list on the objects.

 

Your best bet is to build a wrapper like you have to translate the object into your particular naming convention... but honestly, to me, that seems like a LOT of work to do to simply to satisfy the asthetic of a particular code formatting standard.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available

View solution in original post

5 REPLIES 5
Community Hero

Re: Create Property on Test Object

A test object, as you are trying to work with, isn't a "custom" object open to editing in TestComplete.  The properties/fields/methods come from the application under test.

 

What are you hoping to achieve with this?  We MAY be able to do the same thing but in a different manner.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Community Manager

Re: Create Property on Test Object

Hi @dbattaglia,

 

I agree with Robert - we need some more info to assist you properly. Could you please clarify what property you want to add, and what for?

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
Contributor

Re: Create Property on Test Object

morning! thanks for your replies @tristaanogre and @TanyaGorbunova  and sorry i did not respond sooner...

 

@tristaanogre i get the fact that the test object is an object defined by the application under test, however, there are a number of properties and methods that testcomplete adds to that object reference.

 

what i was hoping to do is just that: add some more properties/methods to the test object, just like the testcomplete engine is doing when it acquires a reference to the object.

 

so in my example, what i'm trying to do is wrap the test objects with plain old python objects (POPO).

but for convenience, i was hoping to be able to create properties/methods on the POPOs that point to the test object properties/methods, but that have custom names.

 

i want to be able to reference the properties/methods of test objects but i want to use snake_case for naming in my project, so on the POPO i want to have mapped_name, not MappedName, and type instead of ObjectType.

 

essentially, what i wanted to do (initially) is to alias existing properties/methods. although, i would also like to add other properties/methods to test objects if this can be done.

i have found many cases where i would like to add customized methods to test objects.

 

right now i have properties on the POPO that are pointing at the test object's properties/methods. like so.

class AwesomeClass():
    name = 'awesome'
    test_object = Aliases.TestObject
    type = self.test_object.ObjectType

so then i can do this to read the ObjectType property of the test object

awesome = AwesomeClass()
if awesome.type == 'Panel':
    ...

but what i would like to do is

class AwesomeClass():
    name = 'awesome'
    test_object = Aliases.TestObject
    self_add_type()

    def add_type(self):
         self.test_object.type = self.test_object.ObjectType

 

again, what i was hoping to accomplish here is to modify the testobject to suit the way i am working with it, creating custom aliases for existing properties/methods, and also to create custom properties/methods.

 

this would be helpful and cleaner i think if it is possible.

please share any suggestions you have.

thanks!

Community Hero

Re: Create Property on Test Object

TestComplete adds them... but as part of the object identification engine built into TestComplete and not in any way accessible to the user.  So, generally, no... you cannot alter the property or method list on the objects.

 

Your best bet is to build a wrapper like you have to translate the object into your particular naming convention... but honestly, to me, that seems like a LOT of work to do to simply to satisfy the asthetic of a particular code formatting standard.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available

View solution in original post

Contributor

Re: Create Property on Test Object

like i said, the naming convention is one aspect.

the other reason is adding custom properties/methods.

i agree that this requires work, everything requires effort.

i am looking at this as foundational work that will enable other things to be built on top.

consistency is critical to building a stable codebase. if the code is not consistent then we have no assurance about what to expect.

 

as i said, i have a means to accomplish what i'm trying to do, that will work.

i was just wondering if there was some secret coolness in the testcomplete that i did not know about.

thanks @tristaanogre 

New Here?
Join us and watch the welcome video:
Top Kudoed Authors