From: Darin Duphorn Date: 2008-02-12T23:55:47+09:00 Subject: Re: How do I get the popup text using watir I got it to work, so now anyone can use it. If you know how do do it better, please add to this thread. #################################################################################Written by: Darin Duphorn #Date: Feb 12, 2008 #Purpose: Handles Popups ################################################################################ require 'watir' require 'watir\contrib\enabled_popup' require 'watir/dialog' require 'watir/winClicker' def startClicker(button) sleep 2 Timeout::timeout(1) do begin hwnd1 = $ie.enabled_popup(9) w = WinClicker.new #Get Popup Text popup_text = w.getStaticText_hWnd(hwnd1) #Verify popup_text match expected text if popup_text.to_s == "Please select an interaction type" # Click buttton w.clickWindowsButton_hwnd(hwnd1, "#{button}" ) #Needed sleep time sleep 0.1 #Check to see if popup still exists Timeout::timeout(1) do begin hwnd = $ie.enabled_popup(9) puts "The popup existed but the expected button didn't exist, so popup was closed without clicking a button" dialog = Watir::Dialog.new dialog.close rescue Timeout::Error puts "The popup existed and the expected button was clicked" end end else #Populates Error Results & Close Dialog puts "Popup existed, but the current text didn't match the expected text, so popup was closed without clicking a button" dialog = Watir::Dialog.new dialog.close end rescue Timeout::Error puts "No Popup existed" end end end # MAIN APPLICATION CODE $ie = Watir::IE.new $ie.goto("https://www-test.redbrickhealth.com/advisor/web/portal/login") $ie.text_field("name","_58_login").set("jadvisor") $ie.text_field("name","_58_password").set("test") $ie.button("type","submit").click $ie.radio(:id,"startInteraction_theInteractionType_id1").set $ie.button(:type, "submit").click_no_wait #Validate Button & Click button startClicker("OK") $ie.waitForIE -- Posted via http://www.ruby-forum.com/.