Hi all
I've been working on a python script that for testing web applications. It:
1) Opens up Internet Explorer
2) Loads a URL
3) Takes a screenshot
4) Compares the screenshot with a previous one
5) Alerts people by email if there is a discrepancy
6) Quits Internet Explorer
It repeats the above process for a number of URLs.
On my development box, it worked fine. When I moved it to a much slower box, with a fresh install of Windows 2k and Python, it started breaking at random:
Quote:
Traceback (most recent call last):
File "apptester.py", line 278, in ?
t.makeGoldenFiles()
File "apptester.py", line 152, in makeGoldenFiles
self.makeGoldenFile( app )
File "apptester.py", line 97, in makeGoldenFile
ie.Visible = 1
File "C:\Python22\Lib\site-packages\win32com\client\dynamic.py", line 521, in __setattr__
raise AttributeError, "Property '%s.%s' can not be set." % (self._username_,
attr)
AttributeError: Property 'InternetExplorer.Application.Visible' can not be set. |
It's breaking before it even gets to do a comparison of screenshots; at the point where it's taking the "good" screenshot.
Note that this doesn't necessarily happen at the same point in the loop. I started adding sleep() calls to give internet explorer time to fully start up, but I'm not sure if that's helping.
I suspect that this is because the new box is so much slower, but I'm not sure.
Here's the bit of code that opens the browser and saves the image:
Code:
def makeGoldenFile( self, app ):
global g_goldenFilesTimeout
ie = win32com.client.Dispatch( "InternetExplorer.Application" )
time.sleep( 2 )
ie.Visible = 1
ie.FullScreen = 1
ie.Navigate( app.url )
time.sleep( g_goldenFilesTimeout )
# Screenshot
fn = app.getGoldenFilename()
cmd = "c:\\PROGRA~1\\CAP\\cap.exe /full /file=" + fn
os.system( cmd )
ie.Quit()
self.addIgnoreAreas( fn, app )
return self.compareScreenshots( fn, app.getGoldenFilename() )
I've highlighted the line Python is complaining about. I've tried increasing the sleep call to 5, but that didn't help (although it did repeat the cycle several more times before breaking).
Any ideas?
-Antun