Forum Discussion

fbordalo's avatar
fbordalo
Occasional Contributor
5 years ago
Solved

Python scripting - way to Initialize IDispatchwrapper shell object

Is there a way to initialize a shell IDispatchwrapper object inside a python script? Can I extend the class (no real need)? .

 

Code snippet:

def func(string):

  shell_idispatcherwapper = <class>

  If not isinstance(string, str):

    return shell_idispatcherwapper

 

  getAllChildren = Aliases.browser.page.tree.FindAllChildren('ObjectType','ListItem',2,True)

  <more code>

  shell_idispatcherwapper= getAllChildren 

  return shell_idispatcherwapper

 

def callFunction()

  obj = function(someObject)

  if not obj.Exists:

    Log.Error("We failed")

  • The IDispatchWrapper that is in TestComplete is not a class or object that you can instantiate or do anything with.  It's part of the applications methodology for identifying objects.  So, if I'm understanding your question, then the answer is: there is no way to initialize the IDispatchwrapper shell object.

7 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    I'm not sure that there is a need for what you're trying to do.  I mean, you're trying to find all list items within a particular tree getAllChildren is that list.  I don't see any need for any other objects or classes.  Can you explain better what you're trying to do?

    • fbordalo's avatar
      fbordalo
      Occasional Contributor

      I want to initialize IDispatchWrapper class at the start of a library function, before running any find command. If the call returns before the find creates the objects, I can rely on object.Exists property. Otherwise, I need to do sothing like this:

       

      var = call the function

      if hasattr(var,'Exists'):

         if var.Exists == Flase:

            exit()

      else:

        if var == False:

            exit()

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        I'm confused... why do you need to Initialize IDispatchWrapper? As I said... there really is no need.  Your "Find" call will do everything you need to find the objects.