I am running this code on the python shell the test was loaded
successfully.  I will illustrate my problem more clearly.  I currently have
a work around by explicitly passing "self" but I'd like to better understand
the issue.  As you can probably tell, I am new to python.

The following code allows me to successfully run a test:
---
import win32com.client
o = win32com.client.Dispatch("QuickTest.Application")
o.Launch()

# i've escaped the \ this time but it also worked the first time
o.Open("C:\\Documents and Settings\\DChung\\Desktop\\XMLRequest")
o.Visible = True
o.Test.Run(o.Test) # this works fine, o.Test.Run() does not.
<python-win32@python.org>---

Using "o.Test.Run()" I get the following:
Traceback (most recent call last):
  File "<pyshell#11>", line 1, in <module>
    o.Test.Run()
  File
"C:\Python31\lib\site-packages\win32com\gen_py\5BF80934-AEDA-4463-B199-B83285266562x0x1x0.py",
line 1717, in Run
    , WaitOnReturn, Parameters)
TypeError: The Python instance can not be converted to a COM object

According to the documentation I should be able to invoke Run() with no
parameters (See below).  I have explicitly passed "self" to the Run method
otherwise I run into the above problem.  When invoking other methods from
this library, i.e. Launch() and Open(), I do not need to pass "self".  I
have since run makepy but the original error I received was:

Traceback (most recent call last):
  File "C:\Documents and Settings\DChung\Desktop\qtptest.py", line 9, in
<module>
    o.Test.Run()
  File "<COMObject <unknown>>", line 3, in Run
TypeError: The Python instance can not be converted to a COM object

Could it be a problem with the COM object?  Why do I need to explicitly pass
a reference to "self" when calling Run (or any other Test object method for
that matter)?

----

Run method signature:
object.Run [ResultsOptions], [WaitOnReturn], [Parameters]

Here is the relevant output of makepy for the QTP Type Library:
class Test(DispatchBaseClass):
...
    def Run(self, ResultsOptions=0, WaitOnReturn=True, Parameters=None):
        """Runs the open test or business component and creates results in
the specified file or Quality Center path."""
        return self._oleobj_.InvokeTypes(15, LCID, 1, (24, 0), ((9, 49),
(11, 49), (9, 49)),ResultsOptions
            , WaitOnReturn, Parameters)
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to