require "watir/winClicker.rb" require 'watir/contrib/enabled_popup' require "watir/WindowHelper.rb" require 'win32ole' # Note that this was not written by me, but is on the watir user guide page. # This is the definition for the pop-up checking/clicking method def dialogExists() hwnd = $ie.enabled_popup(10) $logfile.puts "This is the handle " $logfile.puts hwnd if(hwnd) #Checks for the dialog w = WinClicker.new #Creates a clicker for the OK button on the dialog w.clickWindowsButton_hwnd(hwnd, "OK") # Clicks the OK button return true else return false end end # Here you make sure to use click_no_wait in order to let ruby process the next line $ie.button(:value, "Cancel").click_no_wait #Here is where dialogExists is called dialogExists()