Forum Discussion

harmatii's avatar
Occasional Contributor
5 years ago

Having issues with implementing Page Object Model in TestComplete using Python language

Using TestComplete with Python to automate Desktop project and trying to implement Page Object Model. Have 2 files:


#first file which contains test



import ExcelObjects


def Test001():

  #create object of Excel page class
  eo = ExcelObjects()
  #Runs the "EXCEL" tested application.
  TestedApps.EXCEL.Run(1, True)
  #Maximize window
  #Selects the 'Blank workbook' item of the 'list' select control.



#second file with Page Object which will contain all the locators, methods etc. related to Excel page



class ExcelObjects:
  blank_workbook = Aliases.EXCEL.wndXLMAIN.FullpageUIHost.ListItem("Blank workbook")


And when I run my test it gives me an error: "the object "list" does not exist"

so basically it tries to find this object "blank_workbook = Aliases.EXCEL.wndXLMAIN.FullpageUIHost.ListItem("Blank workbook")" even before it runs TestedApp. any thoughts why it calls that object on the beginning but not at the time where it placed (last step of the test)?


  • You CAN do a POM, but the code is going to probably be more complicated than you want.  NameMapping is what is basically the replacement for POM in Silenium.  All your main actions (click, keys, etc) are on the Alias objects themselves so you don't need, really, to create classes for each of the different objects.  You just need to use NameMapping or one of those other methods that I suggested for building your objects.

6 Replies

  • Wamboo's avatar
    Community Hero


    It comes because you're trying to use an object that's probably not available to you.


    Run it on the debugger and see if these items do not load at the very beginning of the test. If so, change the call to a function and then refer to it in the file.


    Change this into function.

    blank_workbook = Aliases.EXCEL.wndXLMAIN.FullpageUIHost.ListItem("Blank workbook")


    If You are sure that this obj exist while running test. Use WaitChild function of Your's specific object.

    • harmatii's avatar
      Occasional Contributor


      It comes because you're trying to use an object that's probably not available to you.


      Yes, because it tries to find that object before it opens the app.


      It worked after I changed that to a function. But is that possible to have as class attribute not a function?

      Because I'd like to have all locators as an attributes in separate class and then use them in my tests and perform some actions on them (ex: Click(), SetText ..)?

      • tristaanogre's avatar
        Esteemed Contributor

        You can't set UI objects in classes ahead of time.  NameMapping/TestComplete uses a model that you can assign the Alias.blahblahblah to a variable before the object exists... and that variable will contain the object AT THE TIME THAT IT WAS ASSIGNED... so, if the object doesn't exist in the initialization/instantiation of the object, it won't be seen as "existing" when you try and use the property.  UI components need to be assigned or refreshed during execution so that they are found in real-time.  

        You can do some of this if you use WaitChild or WaitAliasChild or FindChild or similar methods to assign the UI object to your class.