[python-win32] win32com and Internet Explorer

Chris Cottee Chris.Cottee at WallStreetSystems.com
Thu Jun 17 12:43:17 EDT 2004


Hi,
	I am trying to automate Internet Explorer using python and win32com
to use it as a functional testing tool. My questions are 
1. Has anyone done this before ? -I am aware of PAMIE and am trying to
extend it.
2. When I use event handling IE takes about ten times longer to navigate and
generally becomes sluggish even if my event handler does nothing. Am I
missing something or is this just normal? I have included
pythoncom.PumpWaitingMessages in the vague hope that it might make a
difference rather than actually knowing what it does...

My test code looks like this:
from  win32com.client import Dispatch,WithEvents
import time,threading,pythoncom,sys

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;
    
time.clock()
ie=Dispatch('InternetExplorer.Application',EventSink)
ev=WithEvents(ie,EventSink)
ie.Visible=1
ie.Navigate("file:///c:/success.html")

waitUntilReady(ie)
print "location",ie.LocationName
ie.Navigate("file:///c:/checkbox.html")
waitUntilReady(ie)
print "location",ie.LocationName
print ie.LocationName,time.clock()
print ie.ReadyState

Thanks for your help,
Chris



More information about the Python-win32 mailing list