Forum Discussion

rushikesh's avatar
rushikesh
Contributor
8 years ago

How to change property of an object in run time while executing the test.

Hello,

 

I want to make use of an object whose property keep changes in a know way during the test.

 

Take a look at attached image 1.

There are 3 objects : 

Each object has height 10.

So,

  Top of object 1 wrt parent object is 0

  Top of object 2 wrt parent object is 10

  Top of object 3 wrt parent object is 20

 

Requirement is to use object Extend2 ( in attached image 1). So i set property of it as Top of object is 20 in NameMapping. Everything works fine.

 

Problem is when there is one more object before Extend2 while test is running. Refer Image 2.

 

Now to if I call Extend2 in my code it refers to Face30, this is because Top of Face30 is 20 now and that of Extend2 is 30.

 

I know at any stage Top of Extend2 will be 10*no of objects.

 

How can I change Top property of Extend2 during test ?

 

Text of object cannot be used as property as I will be running Test in languages other then English and Text will be translated that time. 

 

Any help is appreciated. 

 

 

 

2 Replies

  • cunderw's avatar
    cunderw
    Community Hero

    Using object height is never a good idea for identifying objects, it is to subject to change.

     

    Is this a list? You could just call the list.ClickItem(<item>) and create something that will translate which item you are wanting to click. 

    function selectItem(item,language) {
      let items = {
        item1 : {
          lang1 : "english",
          lang2 : "spanish"
        }
      }
      list.ClickItem(item[item][language])
    }
  • "Top of object" property is not a good choice for identifying the control uniquely. If we cannot use the wndCaption because of multilanguage support we should try to identify another set of properties using which the control can be identified uniquely. If it it not possible to do this with out the language dependent properties we need to use the name mapping configuration feature in test complete. Using this we can use different namemapping configuration for each language and this name mapping configuration selection can be done from script using the NameMapping.CurrentConfigurationName = Namemapping configuration name script. More info can be found in https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/configurations/switching.html