|
The _javascript_ Alert, Confirm, Prompt,
Security, File Save, File Download, File Upload, error message, and login (I think
this is a complete list but there may be others) are all a special type of
modal popup dialog window—there isn’t a different one. In
order to handle these types of popups you have to start another thread independent
of your $ie thread OR you have to not block the process by using click_no_wait. There are two ways (that actually both use
the WInClicker). The first one is listed below that works with the older
versions of Watir. The second (I have found after using them both) is
more reliable than the first but require you having a Watir version greater
than 1079 because of some fixes to click_no_wait (can’t remember the
exact version). You can get them here: http://wiki.openqa.org/display/WTR/Development+Builds
First
method (works with Watir 1.4.x): def jsAlert(button, waitTime = 3) Then, before the button you want to click
that generates the popup, add in: jsAlert("OK", 3) ie.button(:name,
"woohoo").click # This
is the button you want to click that generates the popup Second
Method (faster and more reliable): require 'watir\contrib\enabled_popup' <Your code> $ie.button(“Button Label Text”).click_no_wait # use click_no_wait to click the button
that invokes the JS Alert $ie.button.click_no_wait hwnd =
ie.enabled_popup(5)
# get a handle if one exists if (hwnd)
# yes there is a popup w =
WinClicker.new w.makeWindowActive(hwnd) #
"OK" or whatever the name on the button is w.clickWindowsButton_hwnd(hwnd,
"OK") end NOTE: If you are using IE7 then the title
on the JS Alert box is different then IE6+ so you will need to alter you WinClicker.rb
file for either method. \ruby\lib\ruby\site_ruby\1.8\watir\WinClicker.rb
Lines 113 and 144. IE6 = "Microsoft
Internet Explorer" IE7 = "Windows
Internet Explorer" Hope this helps, --Mark |
_______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
