First, though I looked back at some of your past messages I did not see what version of Ruby you are running. Sometimes click_no_wait will give you that error if you are using 1.8.5. If that is the problem going back to 1.8.4 will solve it.

Second, as Bret mentioned elsewhere, I too have generally found that it works best to wait for the presence of a specific page element, rather than inserting arbitrary sleep times. As a generalization, if the page or dialog is not fully loaded you aren't going anywhere anyway, so you might as well wait for a specific element before you continue. That way you wait for the necessary amount of time, but no longer. I have a custom "wait_for" method that I use for doing this. If you must wait for a page element, in most cases you might as well wait for the last element before you do anything (the last element to appear in the HTML).

There have been rare cases in which waiting for an early element (toward the beginning of the HTML) in the page then acting on it still caused weird timing errors. If you wait for a later element to appear before you act on any page elements, you are more likely to be successful.

Lonny Eachus
=========



Subject:
[Wtr-general] Modal Dialog dismissal launching _javascript_ alert window
From:
Dave Munns <[EMAIL PROTECTED]>
Date:
Fri, 20 Oct 2006 17:33:36 CDT

I have a modal dialog with an OK button. When clicked, the modal dialog is dismissed and a _javascript_ alert window appears with a Close button. I want to click the Close button to dismiss this window.

What I am finding is that usig click_no_wait on the modal dialog OK button does not dismiss the modal dialog and the _javascript_ alert window never appears.

If I use click on the modal dialog OK button instead, the modal dialog is dismissed as desired and the _javascript_ alert window appears as desired, but the the enabled_popup method raises an exception on the line: Watir::until_with_timeout(timeout) do

Example code:

           ie.frame( "fraDataZone" ).image(:id,'imgAction0').click_no_wait #launches modal dialog
            sleep(5)
            if ie.modal_dialog.button( :id, 'imgOKButton' ).exists?
               ie.modal_dialog.button( :id, 'imgOKButton' ).click     # OK, dismiss modal dialog
            end
            
            # Click OK button on _javascript_ Alert window (title is "Microsoft Internet Explorer")
            #
            hwnd = ie.enabled_popup(5)
            if( hwnd )
                w = WinClicker.new
                w.makeWindowActive( hwnd )
                w.clickWindowsButton_hwnd( hwnd, 'imgFinishButton' )
            end
            sleep(3)

This was run with the suggested modification to the enabled_popup method (adding the line: "include Win32" before the line "def enabled_popup(timeout=4). )

I have used sleep stmts to slow things down with the same results. How do I get both the modal dialog and _javascript_ alert window to be dismissed ?
  


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

Reply via email to