egil,

I've been putting recent "downtime" between my primary tasks to polish up my 
homegrown testing app, and the state of the page at the time of errors is 
pretty key. My original idea was to leave the bad page up and refresh the IE 
object to a new instance for the continuation of the test suite, but that was 
sloppy at the very least, and fell far short of the greater goals of the app... 

Anyway, getting off topic. Some comments on the code:

1) right after you require Watir, you have 

[i]KCODE = 'UTF8'
require 'jcode' [/i]

I've commented this out and looked around, but have no idea what it's for... 
can you enlighten me?

2) For the file naming, you've got yourself set up for an infinite loop given 
enough of those files being written. I use numeric incrementation in my files 
in a few places, and have tended towards this snippet:

[i]filenumber = "000"
file_name = "#{basename}_#{filenumber}"
while File.exists?(file_name)
filenumber.succ!
file_name = "#{basename}_#{filenumber}"
end[/i]

This way, if you run over the numeric character field you've given yourself, 
the field just gets bigger. In places where the actual text of the file name is 
less important to me, I increment the entire string rather than just the 
number. It makes for some funky looking file names, but like I said, they 
aren't important to me in those places. 

3) I'm not sure how, but the pages that result from this code are actually 
cleaner looking than those resulting from a manual copy/paste of the "view 
source". Bravo. 

Other than that, I've hijacked this code in it's entirety and am cannibalizing 
it into my own. I've separated the file writing functionality from the page 
capturing functionality - On an error, I catch (rescue) the exception and pass 
the exception type, exception text, call stack, and offending pages code to an 
error logging class (which then constructs a simple html error log and viewer 
for later review and investigation) and re-raise the error exactly as it was 
received for the sake of the testrunner. 

My only other question would be if you able to point me in the direction of 
some decent documentation for getHTML - my searches have been rather fruitless 
thus far. I played with screen_capture, but at the end of the day an image just 
doesn't cut it (app errors handled in the product I am testing display with the 
error messages hidden, and require a knowing javascript event to view), and if 
my devs turn out a particularly bad build, I'd much rather have a few thousand 
html files than images any day.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=4907&messageID=15308#15308
_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to