Hi,
the method we use is a combination of Ruby and Autoit where we write
the contents of the popup to stdout.
Ruby script:
# Creates a process that, after a given timeout,
# kills an internet explorer message window and returns the result.
#
# The success of this class is dependent on the presence of a
compiled
# autoit script called popup_handler.exe, placed in the current ruby
directory.
#
# Throwing a popup handler covers any popups for the next delay
seconds -
# upon the script closing a popup the catchPopupHandler method will
# return its stdout creations
#
class PopupHandler
#
# The process and stdout file pointer to grab input from
#
$fhi
#
# Throws a process that catches internet explorer alert box
contents.
# This, by default, seeks internet explorer 7 window titles.
# To change to ie6 override the optional arguments
#
def PopupHandler.throwPopupHandler(delay = 5, windowTitle = "Windows
Internet Explorer")
$fhi = IO.popen("./popup_handler.exe " + (delay*1000).to_s + " \""
+ windowTitle + "\" &")
end
#
#Returns message or "" if the exe failed to find a window of the
given name.
#
def PopupHandler.catchPopupHandler
message = ""
while (line = $fhi.gets)
if(message == "")
message = line.to_s
else
message = message + "\n" + line.to_s
end
end
return message
end
end
Autoit Script:
$retry_time = 200
$loops = ($CmdLine[1] / $retry_time)
$iterator = 0
$waiting = 1
while($iterator < $loops AND $waiting == 1)
sleep($retry_time)
$iterator += 1;
If(WinExists ( $CmdLine[2] )) Then
WinActivate($CmdLine[2])
$message = ControlGetText($CmdLine[2], '', 65535)
ControlClick($CmdLine[2],'', 2)
ConsoleWrite($message)
$waiting = 0
EndIf
wend
On May 14, 10:35 pm, satish <[email protected]> wrote:
> Can you some one give me an idea how to work with popups.
>
> Here is my requirement.
> -----------------------------------------
> When I click on "Save" image icon on the IE browser, according to data
> validation rules I will get a warning popup box.
>
> I will have to validate the warning message on the popup box whether
> it is correct or not and then needs to respond by click on "OK"
> button.
>
> Can some one give me an idea around this. I am very new to Watir.
> Appreciate your help.
> ========================================================
>
> Here I tried this....but did not work..
> ==============================
> require "watir"
> require "win32ole"
> require "watir/contrib/enabled_popup"
>
> ie.image(:id,
> 'ctl00_contentChildWindow_secUserDetails_ctl02_menu_secUserDetails_DXI0_Img').click
> hwnd = ie.enabled_popup(5)
> if (hwnd) #yeah! a popup
> popup = WinClicker.new
> popup.makeWindowActive(hwnd)
> popup.clickWindowsButton("Windows Internet Explorer", "OK", "30")
> end
> =======================================================>ruby
> Phone_Mask_Test.rb
>
> C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/contrib/
> enabled_popup.rb:5: uninitialized constant Watir::PageContainer::Win32
> (NameError)
> from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> `gem_original_require'
> from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> `require'
> from Phone_Mask_Test.rb:4
>
> >Exit code: 1
>
> Thank you,
> Satish
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines:
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---