David Schmidt wrote:
> Sun,
>
> If the window only has the title "Internet Explorer" then it's not
> likely that it's a modal dialog. This sounds more like an IE warning
> dialog, which is quite different.
>
> I cannot duplicate that warning box on my copy of IE, probably because I
> previously unchecked the box in the warning so I wouldn't see it again.
>
> Here are some ways you should be able to proceed:
>
> First, run the same series of events manually in IE. When you get the
> popup after clicking the "Google Search" button see if there is a
> checkbox you can uncheck so that warning will no longer pop up. Then you
> won't have to handle it at all.
I agree with this suggestion.
> Second, here is how I've handled that type of popup before:
>
> # Change the click to click_no_wait so that any popup won't block Watir
> ie.button(:name, "btnG").click_no_wait
>
> hwnd = ie.enabled_popup( 10 ) # wait up to 10 seconds for a popup to appear
> if( hwnd ) # there is a popup of some kind.
> if( ie2 = ie.modal_dialog(:hwnd, hwnd) ) # if it's a modal dialog
> ie2... # do normal Watir stuff on the modal dialog
> else
> wc = WinClicker.new
> wc.clickWindowsButton_hwnd(hwnd, "OK") # close non-modal popup with
> Handle=hwnd
> end
> end
>
This is probably overkill, but cool nonetheless.
> Now, if there isn't a popup you have to wait until the enabled_popup()
> times out so you may have to tune that value a bit for the particular
> page you're accessing. Sometimes a popup is brought up by the NEW page
> after a click, so you have to wait a bit to make sure the new page has
> loaded before you can check for the popup.
>
> In addition, the ie.modal_dialog call will timeout if the dialog isn't a
> modal_dialog, so you can remove that check if you know that you won't
> get a modal dialog.
>
> In the web scrapers I've done I use a more complex method that uses
> Watir::until_with_timeout to continue as soon as the ie object is no
> longer busy *or* we have an enabled_popup like:
>
> Watir::until_with_timeout(5) { @ie.ie.busy } # Wait until browser gets busy
> Watir::until_with_timeout(90) { [EMAIL PROTECTED] or @ie.enabled_popup(0) }
> sleep 1 # Give IE a chance to fire off a popup on the NEW page.
> Watir::until_with_timeout(90) { [EMAIL PROTECTED] or @ie.enabled_popup(0) }
>
> In any case, this should help you get past the point where you're having
> problems.
>
> David Schmidt
>
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general