Clever code. My problem is slightly different. I am testing a product that uses a web based GUI, by navigating to all GUI controls and collecting data for validation comparisons. This product generates the _javascript_ alert windows to kindly prompt the user that some action has been completed. They lock up the screen until something clicks the OK button on the _javascript_ alert window. I want to code the OK button click for this window, which was opened by the product.

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Adam Reed
Sent: Wednesday, October 04, 2006 1:40 PM
To: wtr-general@rubyforge.org
Subject: Re: [Wtr-general] _javascript_ Alert windows

 

David,

 

    I remember this being in the FAQ and forum posts, but I haven't been in a while -- maybe it was removed (I can't check at the moment).  First you define your script that closes the window (I called it jsAlert).

 

def jsAlert(button, waitTime = 3)
     w = WinClicker.new
     longName = $ie.dir.gsub("/" , "\\" )
     shortName = w.getShortFileName(longName)
     c = "start ruby #{shortName}\\watir\\clickJSDialog.rb #{button} #{waitTime} "
     puts "Starting #{c}"
     w.winsystem(c)
     w=nil
end

 

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

 

Thanks,

 

Adam Reed

RelocationCentral by CORT


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Munns
Sent: Wednesday, October 04, 2006 12:19 PM
To: wtr-general@rubyforge.org
Subject: [Wtr-general] _javascript_ Alert windows

Does Watir have a way of processing _javascript_ Alert windows, by clicking the OK button to dismiss the window? The code that invokes the window issues an alert call with no window handle. I did not find anything on this in the online docs or in the email dist.

_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to