Forum Discussion

iamaqa's avatar
iamaqa
New Contributor
3 years ago

modularize object path

TestComplete version: 15.42.9.7 x64

I'm using python for the Unit test script.

 

Question: how do you modularized an object path in TestComplete?

 

example

 

from this:

aqObject.CheckProperty(Aliases.ApplicationName.HwndSource_MainWindow.MainWindow.StatusBar.StatusBarItem.TextblockJohnDoe, "WPFControlText", cmpEqual, "john.doe")

 

to something like this:

UserName= "john.doe"

TextBlock="Aliases.ApplicationName.HwndSource_MainWindow.MainWindow.StatusBar.StatusBarItem.Textblock"

 

aqObject.CheckProperty(TextBlock+UserName.title().replace(".",""), "WPFControlText", cmpEqual, UserName)

  • I found a solution and it's working!

    need to use the eval() function to convert string to a python object

     

    aqObject.CheckProperty(eval(TextBlock+UserName.title().replace(".","")), "WPFControlText", cmpEqual, UserName)

  • iamaqa's avatar
    iamaqa
    New Contributor

    I found a solution and it's working!

    need to use the eval() function to convert string to a python object

     

    aqObject.CheckProperty(eval(TextBlock+UserName.title().replace(".","")), "WPFControlText", cmpEqual, UserName)