Forum Discussion

Xavi's avatar
Xavi
Occasional Contributor
1 month ago
Solved

Issues upgrading from 15.7 to 15.8 version

Dear,

After upgrade TestComplete from 15.7 to 15.8 version, some issues appeared.

     Python runtime error - NameError: name 'Aliases' is not defined
     Python runtime error - NameError: name 'Log' is not defined
     Python runtime error - NameError: name 'Project' is not defined
     Python runtime error - NameError: name 'aqObject' is not defined
     Python runtime error - NameError: name 'ADO' is not defined

The support team suggested us to add this header line to all the project scripts:

     from tc import *

And to add this prefix:

     tc.Aliases.Client ...
     tc.Log.Message(...)
     tc.aqObject.GetVarType(ColumnId)
     tc.ADO.CreateADOQuery()

But, this solutions not resolves the issues.

Has someone had the same problem in order to help us ?

Thanks, Xavi

  • I would like to explain you the used way to resolve our latest problems with TC and Python.

    The problem is when we use scripts stored in a different root path. When the scripts are stored in subfolders, they can’t be found.

    We applied the “Centralizing Global Imports in a Shared Configuration File” for this link:

    Working with TestComplete Global Objects in Python 3.13 | TestComplete Documentation

    This global file, is important to create in the root path:

    After create the global file, the scripts stored in the root path don’t need a prefix to refer to the objects.

    The scripts stored in subfolders, need to use a prefix to refer to the objects:

                   import globals_tc as ag

                    ag.Aliases.Client…
                    ag.Log…
                    …

    Thanks,

8 Replies

  • mcpm's avatar
    mcpm
    Occasional Contributor

    Hello, this way:
    from tc import *
    also didn’t work for me, but try this:


    from tc import Aliases, Log, ADO

    and so on. 

    Then:
    Aliases.Client(...) 
    Log.Message(...) 

    If you want to try it this way (but I didn't use that): 
    tc.Aliases.Client(...),


    you need to import the namespace first:
    import tc

    I hope it helps
    Paweł

    • Xavi's avatar
      Xavi
      Occasional Contributor

      Hello,

      I tried you suggested solution, but it crashes on the header imports, maybe something wrong for my self ?

      Thanks, Xavi

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    The latest version of TestComplete comes with Python 3.13. Python has made a number of changes. One of them is treating global as regular scoped objects, which has impacted Python scripts used in TestComplete.

    See https://support.smartbear.com/testcomplete/docs/scripting/specifics/python_tc_globalobjects.html for more information. You need to update your Python scripts to accommodate this change.

    As an example, Log is being passed as a parameter -

    MainTest.py

    import MyFunctions
    
    def main():
      MyFunctions.greet(Log, "Alice")

    MyFunctions.py

    def greet(Log, name):
      Log.Message(f"Hello, {name}!")

    Same issue has been discussed here, 

    TestComplete 15.77 is broken - dont upgrade | SmartBear Community 

     

     

      • rraghvani's avatar
        rraghvani
        Icon for Champion Level 3 rankChampion Level 3

        Remove "tc" from "tc.Aliases.Client". Try this for example,

        Unit1.py

        import Unit2
        
        def main():
            Unit2.datetime()

        Unit2.py

        from tc import aqDateTime
        # or from tc import *
        
        def datetime():
            return aqDateTime.Now()

        If you have a big project, it is a pain to update. However, there's no way around this, as Python have made these changes.

  • Xavi's avatar
    Xavi
    Occasional Contributor

    I would like to explain you the used way to resolve our latest problems with TC and Python.

    The problem is when we use scripts stored in a different root path. When the scripts are stored in subfolders, they can’t be found.

    We applied the “Centralizing Global Imports in a Shared Configuration File” for this link:

    Working with TestComplete Global Objects in Python 3.13 | TestComplete Documentation

    This global file, is important to create in the root path:

    After create the global file, the scripts stored in the root path don’t need a prefix to refer to the objects.

    The scripts stored in subfolders, need to use a prefix to refer to the objects:

                   import globals_tc as ag

                    ag.Aliases.Client…
                    ag.Log…
                    …

    Thanks,