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.
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
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
Sun wrote:
> I have a popup titled simply "Internet Explorer" containing the text: "When
> you send information to the Internet, it might be possible for others to see
> that information. Do you want to continue?" There are two buttons, labeled
> "Yes" and "No".
>
> I am unable to attach to this like so: ie2 = Watir::IE.attach(:title,
> ‘Internet Explorer’), or by doing: ie2 = Watir::IE.attach(:title,
> /Internet/). This made me suspect this was a modal dialog (besides the fact
> that it acts like one functionally.)
>
> This pops up, by the way, when I execute the script googleSearch.rb (you
> know, the pickaxe script referenced in the Watir user guide.) It happens
> after the script sends the click to the Google Search button.
>
> So...I uninstalled Watir 1.4.1, downloaded the current 1.5 gem (currently
> watir-1.5.1.1065.gem) and installed the gem. So far so good. This was to gain
> modal dialog processing functionality.
>
> I then inserted this statement: ie.modal_dialog.button(:text, "Yes").click
> immediately after these 3 lines in the script:
> =>puts "Step 3: click the 'Google Search' button"
> =>ie.button(:name, "btnG").click # "btnG" is the name of the Search button
> =>puts " Action: clicked the Google Search button."
>
> No good. After step 2 completes (pickaxe loaded into google search field) I
> see:
> "Step 3: click the 'Google Search' button
> Action: clicked the Google Search button.
> Modal Dialog not found. Timeout = 2.0
> c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1065/./watir.rb:2606:in `locate'
> Press ENTER to close the window..."
>
> Now, my BELIEF is that the reason this occurs is that this dialog popup is
> not launched by Javascript from the current IE session -- but rather is
> triggered by IE security. Which since I am testing a corporate browser I
> cannot alter. So -- has anyone dealt with this before? I haven't seen any
> postings in this forum or elsewhere on the web about dealing with Browser
> security generated dialogs....
>
> Has anyone dealt with this standard security modal dialog before? If so, what
> should I add to that simple googleSearch.rb to get past it automatically
>
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general