Forum Discussion

Likstern's avatar
New Contributor
7 years ago

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?

2 Replies