Sounds like what you need is to start a separate process or thread to
wait for, then interact with, the dialog.

As you've seen, for this type of dialog task, there's more than one
way to do it. :)  And as far as I know the Watir community does not
endorse any single "right" way to handle SSL dialogs.  Many have
tackled the problem, but but no single attempt has emerged as the
clear winner yet.

Also, as Bret mentioned on the list recently, dialog issues can also
be solved by taking steps to prevent the dialog from appearing at all.
 In your case (since it's an SSL-related dialog with a "Yes" button)
it sounds like you're seeing the "Yes/No/Cancel" alert indicating that
IE does not trust the certificate.  You can avoid that dialog by
importing the site's SSL cert into your trusted certificate store in
IE.  (This is worth investigating if the certificate does not change
often.)

But as for how to automate clicking on the "Yes" button, try this.
It's clunky, but until a better solution comes along, this pattern
works.

1) Create a new file, named:

click_yes_ssl_cert_dialog.rb

2) Inside it, paste the necessary code to click the dialog's 'Yes' button:

require 'watir'

Watir.autoit.WinWait "Security Alert", ""
Watir.autoit.ControlClick "Security Alert", "", "&Yes"

3) Now, back in your primary script, invoke the helper script just
before you call IE.start_process.  You can use this line:

system('start click_yes_ssl_cert_dialog.rb')

That fires off a second command interpreter and to run the helper
script, and the script does not wait for it to return.  So your main
script can continue on to start the browser while the helper script
churns away in the background waiting for the dialog.


An important note: Be sure to place the main script and the helper
script in the same directory, and launch the main script from that
directory as well.  If you try launching the script from a different
dir, you'll need some extra code to make sure the main script can find
the helper script.


On 12/3/08, winstan <[EMAIL PROTECTED]> wrote:
>
> Hi Bill,
>
> You're correct, as soon as the browser tries to navigate to that URL
> it just hangs as it cannot control the "Security Alert" pop up dialog
> and accept yes. Out of all the examples that i have attempted in my
> script, which one would you suggest i use and attempt to get working.
>
> I just attempted to do as you stated by moving the popup-handling code
> above the "ie = Watir::IE.start_process(webserv_v4)" but still the
> same issue is evident where it cannot handle the pop-up, hence my
> above question.
>
> Thanks for your assistance with this.
>
> On Dec 4, 3:10 pm, "Bill Agee" <[EMAIL PROTECTED]> wrote:
> > Does your script block at the following line and not continue?  Or is there
> > some other problem?
> >
> > ie = Watir::IE.start_process(webserv_v4)
> >
> > If that line is where things go wrong, try moving the popup-handling code
> > above that line - otherwise the Security Alert dialog is probably going to
> > prevent your script from reaching the next line.
> >
> > On Wed, Dec 3, 2008 at 5:02 PM, winstan <[EMAIL PROTECTED]>wrote:
> >
> >
> >
> >
> >
> > > Hey Guys,
> >
> > > Second post here, and unfortunately, is related to a topic that has
> > > been discussed to no end. The security alert pop-up associated with
> > > IE6 and certificated URL's. I have searched high and low and have
> > > tried every possible solution I have come by but still to no prevail,
> > > I still can't click the yes on the security alert dialogue. Please
> > > could you more savvy water guys take a look at my script and perhaps
> > > point me in the right direction.
> >
> > > Bear in mind it is a mess as I have been trying to resolve the
> > > security pop up issue I am having and at the same time this is just a
> > > simple spike script as a proof of concept.
> >
> > > Many thanks with anticipation.
> >
> > > W
> >
> > > ===========================================================================­=====
> >
> > > require 'watir'
> > > require 'watir/ie'
> > > require 'watir/contrib/enabled_popup'
> > > require 'watir/WindowHelper'
> > > require 'watir/winClicker'
> >
> > >  def push_security_alert_yes
> > >        Watir.autoit.WinWait "Security Alert", ""
> > >        Watir.autoit.Send "{TAB}"
> > >        Watir.Send "{TAB}"
> > >        Watir.Send "{SPACE}"
> > >    end
> >
> > > #def startClicker(browser, button_label, waitTime= 9, user_input=nil)
> > >  # get a handle if one exists
> > >  #hwnd = browser.enabled_popup(waitTime)
> > >  #if(hwnd)  # yes there is a popup
> > >    #w = WinClicker.new
> > >    #if(user_input)
> > >      #w.setTextValueForFileNameField(hwnd, user_input.to_s)
> > >    #end
> > >    # I put this in to see the text being input it is not necessary to
> > > work
> > >    #sleep 3
> > >    # "OK" or whatever the name on the button is
> > >    #w.clickWindowsButton_hwnd(hwnd, button_label.to_s)
> > >    # this is just cleanup
> > >    #w = nil
> > >  #end
> > > #end
> >
> > > webserv_v4 = 'https://sensitiveurl.com'
> > > rdm_sit = 'http://sensitiveurl.com'/'
> >
> > > #puts "Opening new browser"
> > > #puts ""
> > > #ie = Watir::IE.new
> > > #ie = Watir::IE.new
> > > #ie.maximize
> >
> > > puts "Step 1: point browser to the Web Server v4"  + webserv_v4
> > > puts""
> > > ie = Watir::IE.start_process(webserv_v4)
> >
> > > wc = WinClicker.new
> > > wc.clearSecurityAlertBox()
> >
> > > #helper = WindowHelper.new
> > > #helper.push_security_alert_yes()
> >
> > > #        Watir.autoit.WinWait "Security Alert", ""
> > > #        Watir.autoit.Send "{TAB}"
> > > #        Watir.autoit.Send "{TAB}"
> > > #        Watir.autoit.Send "{SPACE}"
> >
> > > #push_security_alert_yes
> >
> > > #startClicker(ie,"Yes")
> >
> > > ===========================================================================­=====-
> > >  Hide quoted text -
> >
> > - Show quoted text -
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to