scripting - Error "The object invoked has disconnected from its clients" - automate IE 8 with python and win32com -
scripting - Error "The object invoked has disconnected from its clients" - automate IE 8 with python and win32com -
i automate net explorer 8 (using python 2.7 on windows 7) machine. here code after a post found on so:
import sys, time win32com.client import withevents, dispatch import pythoncom import threading stopevent=threading.event() class eventsink(object): def onnavigatecomplete2(self,*args): print "complete",args stopevent.set() def waituntilready(ie): if ie.readystate!=4: while 1: print "waiting" pythoncom.pumpwaitingmessages() stopevent.wait(.2) if stopevent.isset() or ie.readystate==4: stopevent.clear() break; if __name__ == '__main__': time.clock() ie=dispatch('internetexplorer.application',eventsink) ev=withevents(ie,eventsink) ie.visible=true ie.addressbar = true ie.navigate("http://www.sap.com/austria/index.epx") waituntilready(ie) i got next error message http://www.sap.com/austria/index.epx:
waiting waiting traceback (most recent phone call last): file "c:\users\w\my documents\aptana studio 3 workspace\myapp\src\gotoideawindow.py", line 41, in <module> waituntilready(ie) file "c:\users\w\my documents\aptana studio 3 workspace\myapp\src\gotoideawindow.py", line 26, in waituntilready if stopevent.isset() or ie.readystate==4: file "c:\python27\lib\site-packages\win32com\client\__init__.py", line 463, in __getattr__ homecoming self._applytypes_(*args) file "c:\python27\lib\site-packages\win32com\client\__init__.py", line 456, in _applytypes_ self._oleobj_.invoketypes(dispid, 0, wflags, rettype, argtypes, *args), pywintypes.com_error: (-2147417848, 'the object invoked has disconnected clients.', none, none) the code works for, e.g., google.com or bbc.com. know reason?
on ie9, need lower security settings create script work:
ie9 -> net options -> security -> trusted sites : low ie9 -> net options -> security -> net : medium + unchecked enable protected mode ie9 -> net options -> security -> restricted sites : unchecked enable protected mode python scripting ole win32com
Comments
Post a Comment