1.) You need to update the winClicker.rb file in your watir directory (in my case, it was at: c:\ruby\lib\ruby\gems\1.8\gems \watir-1.5.3\watir).Change the dialog title from "Internet Explorer" to "Windows Internet Explorer".I used the regex /Internet Explorer/ so that it will work no matter which version of IE I use.
2.)Require 'watir/contrib/enabled_popup' for your tests.
3.)Define the popupChecker method to watch for a popup and dismiss it (in this case, by clicking the button with the specified text):
def popupChecker(text)
Timeout::timeout(2)do
begin
if $ie.enabled_popup
hwnd = $ie.enabled_popup(5)
w = WinClicker.new
w.makeWindowActive(hwnd)
w.clickWindowsButton_hWnd(hwnd, text)
end
rescue Timeout::Error
puts 'No popup existed'
end
end
end
4.)Use the click_no_wait method on the link or button that will launch the popup.
ie.button(:text, 'Continue').click_no_wait
5.)Call the popupChecker method in case a popup exists
popupChecker('OK')
Showing posts with label Pop ups in Watir. Show all posts
Showing posts with label Pop ups in Watir. Show all posts
Tuesday, June 2, 2009
Subscribe to:
Posts (Atom)