Forum Discussion

dbattaglia's avatar
6 years ago

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.



test_object = Aliases.Object

test_object.some_property = 'some important text'


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.


  • 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.

5 Replies

  • tristaanogre's avatar
    Esteemed Contributor

    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.

    • TanyaYatskovska's avatar
      SmartBear Alumni (Retired)

      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?

      • dbattaglia's avatar

        morning! thanks for your replies tristaanogre and TanyaYatskovska  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
            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.