I know, yet another issue with pop ups regarding watir. Let me start by saying I've been using watir for the past 4 years and love it. That is, until our developers got cute and started using Ajax jQuery javascript to confirm if a user really wanted to delete something.
We have a regular javascript pop up in our application which I was successfully able to handle thanks to the many posts in this forum, but for the life of me I can't get this Ajax pop up to work. To start, what I have working: The call I am using to produce the regular javascript pop up is: $ie.link(:text , "Go").click! I then call the following method: def startClicker( browser, button , waitTime= 10) # get a handle if one exists puts "in Start Clicker" Timeout::timeout(2) do hwnd = browser.enabled_popup(waitTime) if (hwnd) # yes there is a popup puts "there is a pop up" w = WinClicker.new # "OK" or whatever the name on the button is w.clickWindowsButton_hwnd( hwnd, "#{button}" ) # # this is just cleanup w=nil else puts "there is no pop up" end end end Which is successful. Yay, a success story :) Now the fun. The following is what I call to produce the Ajax Confirm Deletion pop up: $ie.link(:title, "Delete watir").click! I have tried startClicker($ie, "OK") and get the following error: Timeout::Error: execution expired c:/ruby/lib/ruby/1.8/timeout.rb:54:in `sleep' I have also tried autoit with the following: def autoitStartClicker() puts "in autoitStartClicker" autoit = WIN32OLE.new('AutoItX3.Control') autoit.WinWait('Confirm Deletion', '', 5) autoit.ControlClick("Confirm Deletion", "", "[CLASS:Button; TEXT:OK]") autoit.Send('{OK}') end and got no errors and no results either. When doing these steps in IRB, I get: irb(main):011:0> ie.link(:title, "Delete watir").click! => "" irb(main):012:0> autoit = WIN32OLE.new('AutoItX3.Control') => #<WIN32OLE:0x45d05f8> irb(main):013:0> autoit.WinWait('Confirm Deletion', '', 5) => 0 irb(main):014:0> autoit.ControlClick("Confirm Deletion", "", "[CLASS:Button; TEXT:OK]") => 0 irb(main):015:0> so it is able to create the win32ole autoit object, but it can't seem to find my Confirm Deletion pop up, hence =>0. Which is even more evident from: irb(main):015:0> autoit.WinActivate('Confirm Deletion') => nil I also tried to attach to the pop up as if it were another window: irb(main):016:0> pop_up = Watir::IE.attach(:title, 'Confirm Deletion') Watir::Exception::NoMatchingWindowFoundException: Unable to locate a window with title of Confirm Deletion Then I tried the following (which mentions it is suppose to start some Ajax stuff): irb(main):018:0* ie.link(:url, %r|ConfirmDeletion|).click Watir::Exception::UnknownObjectException: Unable to locate element, using :url, /ConfirmDeletion/ The javascript code used to delete the entity is: $(document).ready(function() { $('.ajaxDeleteButton') .click(function(i){ deleteButton($(this)) return false; }) }); function deleteButton(button) { jConfirm('Do you really want to delete?', 'Confirm Deletion', function (r) { if (r == true) { button.find("img").hide().attr("src", "images/ processing.gif").fadeIn("slow", function() { doDelete(button); }); } }); } function doDelete(button) { jQuery.ajax({ type: "POST", url: button.attr("href"), success: function(msg) { var row = button.parent().parent(); if (msg == 1) { row.remove(); $(".stripey tr").removeClass("odd"); $(".stripey tr:odd").addClass("odd"); if(button.hasClass("reloadAfterDelete")) { window.location.reload(true); } } else { row.find("td:first").addClass("errorTxt").prepend("This item is in use and cannot be deleted.<br />"); button.remove(); } } }); } I have discussed this issue with my developers and we are all hoping we can find a way for watir to handle this so they don't have to modify their code. We are just now at the stage where we are getting our watir scripts to run with cruise control for nightly tests, but without being able to click OK on this Confirm Deletion pop up, some assert tests are failing. I hope I've offered enough information here to get some discussion, but if you have any questions on specifics, please ask. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~----------~----~----~----~------~----~------~--~---