Egil Sorensen wrote:
> You write that for your third option (using getHTML) that you won't get
> the Internet Explorer's DOM in its exact visual state.
If I were insanely pursuing that option, I would try to get things like the
little floating <div> in GMail that points down to the name of the next
thread author.
That's just a goal; for now I'm only curious about grabbing whatever's easy!
Here's some Q and A about your lines...
> require 'jcode'
Uh, Japanese?
> file_name = "#{basename}_#{sprintf("%03d",no)}.html" # ex.:
> watir_pagecapture_001.html
Parenthetically, my test rig names each snapshot after the title of the test
case. Next, I will convert this file into a PNG using a little program I
wrote called snapshot.exe. So others will need the above code, but I will
just nab a temporary HTML and give the PNG file the final name.
> html = ie.document.body.parentelement.outerhtml
Kewl. The outermost DOM thing, regardless what it thinks its type or name
is!
> html.sub!(/<HEAD>/i,"<HEAD>\n<BASE HREF=\"#{url}\">\n")
I worked-around that by sticking the BASE HREF at the front of the file,
outside the <HEAD>. This will rely on (shocked gasp) browser forgiveness!
But my snapshot.exe doesn't care...
> html.sub!('<META http-equiv=content-type content="text/html;
> charset=UTF-8">',
> '<!-- <META http-equiv=content-type content="text/html;
> charset=UTF-8"> -->')
Oookay. The only problem I can think of there is HTML is _already_ UTF-8
unless you specify otherwise, so either your browser dislikes redundancy, or
something else is going on!
In conclusion, thanks! I will replace the getHTML with that, to force a more
accurate snapshot.
--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general