cancel
Showing results for 
Search instead for 
Did you mean: 

Python scripting - way to Initialize IDispatchwrapper shell object

SOLVED
Occasional Contributor

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")

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Python scripting - way to Initialize IDispatchwrapper shell object

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.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available

View solution in original post

7 REPLIES 7
Highlighted
Community Hero

Re: Python scripting - way to Initialize IDispatchwrapper shell object

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?


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Occasional Contributor

Re: Python scripting - way to Initialize IDispatchwrapper shell object

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()

 

Community Hero

Re: Python scripting - way to Initialize IDispatchwrapper shell object

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.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Occasional Contributor

Re: Python scripting - way to Initialize IDispatchwrapper shell object

Have you worked with flex?

I am building library functions for each flex object, which in term is called by other scripts. I need a way to pass a consistent object. To make matter worse, these objects are dynamic and reused.

Community Hero

Re: Python scripting - way to Initialize IDispatchwrapper shell object

Hi,

 

Hm-m-m... I am second to Robert and still not sure that I have a clear understanding of what you'd like to get...

Maybe more detailed example will help...

 

> objects are dynamic and reused.

Note, that if some object is destroyed and recreated in your tested application, the reference to the initial object in test code in TestComplete becomes invalid and cannot be 'refreshed'. You must search for a new object anew, even if all search criteria are the same.

For sure the exact test code implementation depends on your tested application, but as a rule globally kept references to objects from the tested application are not recommended because they can invalidate at any moment and the code that verifies reference validity and searches for the object anew adds unnecessary complexity. Usually it is faster and more convenient to search for the object where needed and dispose of the reference to the found object as soon as the operation over the object is completed.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Occasional Contributor

Re: Python scripting - way to Initialize IDispatchwrapper shell object

I don't know how to or want to explaining further. I think my question is clear, the usage is irrelevant.
How can I initialize the IDispatchwrapper without searching for an object.

Sorry for my short reply, but sometimes the user want's to try things for them self.

 

 

Community Hero

Re: Python scripting - way to Initialize IDispatchwrapper shell object

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.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available

View solution in original post

New Here?
Join us and watch the welcome video:
Top Kudoed Authors