Everyone, Canoo WebTest has a nice feature whereby the HTML pages of the application under test are saved for viewing later, which is very handy when a test case fails.
So, I went looking for something similar in Rubyland, and ran across this posting. http://rubyforge.org/pipermail/win32utils-devel/2005-April/000358.html With some modification (since I want to save the HTML, not get a screen print), I came up with the following code that doesn't quite work. As a bonus, it somehow hoses Windows (DOS command windows become gigantic and non-functional, keyboard input no longer functions, etc.) Any Win32 experts see what I've left out? Thanks in advance! Joe class SaveWebPage require 'Win32API' def initialize @KEYEVENTF_KEYUP = 0x2 @SW_HIDE = 0 @SW_SHOW = 5 @SW_SHOWNORMAL = 1 @VK_CONTROL = 0x11 @VK_F4 = 0x73 @VK_MENU = 0x12 @VK_RETURN = 0x0D @VK_SHIFT = 0x10 @VK_SNAPSHOT = 0x2C @VK_TAB = 0x09 end # Use IE's "save page as" menu selection (Alt, F, A, S) def save_page keybd_event = Win32API.new("user32", "keybd_event", ['I','I','L','L'], 'V') vkKeyScan = Win32API.new("user32", "VkKeyScan", ['I'], 'I') keybd_event.Call(@VK_MENU, 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?F), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?A), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?S), 1, 0, 0) end end _______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
