Hello, I am a beginner with Watir, right now using 1.5.1.1065. And I still cannot make the code work for closing password popups or certificate alert popup (meaning clicking on the OK button).
So here is what I can give you, I have put together all the different scripts/solutions possible, and I have included my script below as well. Hope this compilation can help out, and if anybody can help me fix my problem or show me the way to do it, I would greatly appreciate it. I tried Autoit, WindowHelper and others. Thank you in advance for any help. David. Autoit # Auto Popup Handler. # require 'win32ole' # already included if you use 'require watir' # # Function to look for popups def check_for_popups autoit = WIN32OLE.new('<nowiki>AutoItX3</nowiki>.Control') # # Do forever - assumes popups could occur anywhere/anytime in your application. loop do # Look for window with given title. Give up after 1 second. ret = autoit.<nowiki>WinWait</nowiki>('Popup Window Title', '', 1) # # If window found, send appropriate keystroke (e.g. {enter}, {Y}, {N}). if (ret==1) then autoit.Send('{enter}') end # # Take a rest to avoid chewing up cycles and give another thread a go. # Then resume the loop. sleep(3) end end # # MAIN APPLICATION CODE # Setup popup handler $popup = Thread.new { check_for_popups } # start popup handler at_exit { Thread.kill($popup) } # kill thread on exit of main application # WinClicker #define the popup method first (this is right out of unittests\popups_test.rb) def startClicker( button , waitTime = 3) w = WinClicker.new longName = $ie.dir.gsub("/" , "\\" ) shortName = w.getShortFileName(longName) c = "start rubyw #{shortName }\\watir\\clickJSDialog.rb #{button } #{ waitTime} " puts "Starting #{c}" w.winsystem(c) w=nil end #then call it just before your button click startClicker("OK" , 3) $ie.button("Submit").click JS POPUP # method to click JS popups def startClicker( 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 # just before your button that invokes the JS popup put this: startClicker("OK" , 3) $ie.button(‘Submit’).click My beginner script require 'watir' include Watir require 'test/unit' class TC_100 < Test::Unit::TestCase def test_100 ie = IE.new # when reaching the below url, I get a password popup, I have already prepopulated, waiting for me to click the ok button ie.goto('http://qa.mysite.com/') ie.text_field(:name, 'words').set('9999999') ie.button(:name, 'go').click ie.text_field(:name, 'q1').set('1') ie.button(:name, 'pip_add').click ie.text_field(:name, 'words').set('888888') ie.button(:name, 'go').click ie.text_field(:name, 'q2').set('1') ie.button(:name, 'pip_add').click ie.goto('http://qa.mysite.com/newpage') ie.button(:name, 'checkout').click # after clicking that button I get the password popup again and then a certificate popup, password is waiting for OK, certificate is waiting for YES ie.text_field(:name, 'n1').set('test1') ie.text_field(:name, 'a1').set('50 ST') ie.text_field(:name, 'c1').set('Portland') ie.select_list(:name, 's1').select_value('OR') ie.text_field(:name, 'z1').set('97204') ie.text_field(:name, 'p1').set('7771110909') ie.button(:name, 'continue').click ie.button(:name, 'continue').click ie.select_list(:name, 'paytype').select_value('0') ie.text_field(:name, 'ccnum').set('XXXXXXXXXXXXXXXX') ie.select_list(:name, 'expm').select_value('xx') ie.select_list(:name, 'expy').select_value('xxxx') ie.text_field(:name, 'cvn').set('000') ie.button(:name, 'placeorder').click end end -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.11.4/424 - Release Date: 8/21/2006 _______________________________________________ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general