[Wtr-general] How do I click the "OK" button on a java alert?
Cain, Mark
Mark_Cain at RL.gov
Tue Jan 2 11:09:29 EST 2007
I have found Autoit a little flaky. You can use what is already built
into Watir. Here is a method I wrote to handle most of my popup needs..
You will need to use the newest gem if Watir (get it here
http://wiki.openqa.org/display/WTR/Development+Builds) :
require 'watir\contrib\enabled_popup'
def startClicker( button , waitTime=9, user_input=nil)
hwnd = $ie.enabled_popup(waitTime) # get a handle if one exists
if (hwnd) # yes there is a popup
w = WinClicker.new
if ( user_input )
w.setTextValueForFileNameField(hwnd, "#{user_input}")
end
sleep 3 # I put this in to see the text being input it is not
necessary to work
w.clickWindowsButton_hwnd(hwnd, "#{button}") # "OK" or whatever
the name on the button is
w=nil # this is just cleanup
end
end
$ie=Watir::IE.start("c:\test.htm")
# This is whatever object that uses the click method.
$ie.image(:id,'3').click_no_wait
startClicker("OK", 7, "User Input") # 3rd parameter is optional.
Hope this helps
--Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20070102/f704eaec/attachment-0001.html
More information about the Wtr-general
mailing list