Ask a Question

Win32com can be used only one time

New Contributor

Win32com can be used only one time

Test Complete 11.31

Python 3.4


Trying to import win32com.client

import sys

sys.path.insert(0, 'C:\Program Files (x86)\SmartBear\TestComplete 11\Bin\Extensions\Python\Python34\Lib\site-packages')
sys.path.insert(0, 'C:\Program Files (x86)\SmartBear\TestComplete 11\Bin\Extensions\Python\Python34\Lib\win32')
sys.path.insert(0, 'C:\Program Files (x86)\SmartBear\TestComplete 11\Bin\Extensions\Python\Python34\Lib\win32\lib')
import win32com.client


def test(self):

    SapGuiAuto = win32com.client.GetObject("SAPGUI")
    if not type(SapGuiAuto) == win32com.client.CDispatch:


   application = SapGuiAuto.GetScriptingEngine
   if not type(application) == win32com.client.CDispatch:
       SapGuiAuto = None


   connection = application.Children(0)
   if not type(connection) == win32com.client.CDispatch:
      application = None
      SapGuiAuto = None


    session = connection.Children(0)
    if not type(session) == win32com.client.CDispatch:
        connection = None
        application = None
        SapGuiAuto = None


First run is ok.

Second run: import failed with 'NoneType' object is not callable.

When i run this code in pycharm - everything is ok
How it can be solved?

Community Hero

I suggest contacting Support directly about this.  You can use this link:

[Community Hero]
[Community Heroes] 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. Posts made by [Community Heroes]
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.
The [Community Hero] signature is used with permission by SmartBear Software.
Esteemed Contributor

Where does the package for win32com reside?  If it's not in those extensions folders, TestComplete may not be able to access it.

Robert Martin
[Hall of Fame]
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
Vegas Thrill Rider
Extensions available
Showing results for 
Search instead for 
Did you mean: