[Wtr-general] Multiple Security alerts

Mike Townley mtownley at firstlook.biz
Mon Aug 7 18:15:00 EDT 2006


Hello, 

I am trying to automate the login for a web application that presents
more than one security alert. The first is presented for the SSL
connection to the login page. The login page is a front end for CAS
(central authentication service) CAS has then opens an SSL connection to
one of the load balanced instances of tomcat. This results in getting
two security popups. 

 

Before this CAS set up was implemented, we just had one security alert
that was simply handled with the multi-threaded solution shown on the
wiki for WATIR 1.4

The old scheme basically created a thread to monitor the presense of a
popup and click ok if it found one, and also to pass the code block that
causes the popup to another thread. I have tried nesting them but that
doesn't seem to do it.

 

Example;

 

if conf.has_security_alert

Popup.new(@ie, "Security Alert", fast_popup=true).click_ctl("&Yes")
{@ie.goto(url <mailto:%7b at ie.goto(url> )} //Original method, works fine
for one pop up. Passes whatever is in {} to the other thread while the
main thread looks for the popup. 

 

Here is what I have tried with no luck

 

if conf.has_security_alert

Popup.new(@ie, "Security Alert", fast_popup=true).click_ctl("&Yes")
{Popup.new(@ie, "Security Alert", fast_popup=true).click_ctl("&Yes")
{@ie.goto(url <mailto:%7b at ie.goto(url> )}}

 

Also tried;

 

 

Popup.new(@ie, "Security Alert", fast_popup=true).click_ctl("&Yes")
{@ie.goto(url <mailto:%7b at ie.goto(url> ) Popup.new(@ie, "Security
Alert", fast_popup=true).click_ctl("&Yes") {@ie.goto(url
<mailto:%7b at ie.goto(url> )} }

 

Here is where I define the class Popup

 

require 'watir'

require 'win32ole'

 

class Popup

 

            # 02/16/06 KL:  fast_popup indicates whether or not you're
interacting with a popup

            # that displays before the step that triggered it even
completes.  the security alert

            # popup, for example, is displayed before the beta login
page has finished loading.

 

            def initialize(ie, win_title, fast_popup)

                        

                        @ie = ie if ie

                        

                        if win_title.nil? or win_title == "" then

                                    @win_title = "Microsoft Internet
Explorer"

                        else

                                    @win_title = win_title

                        end

                        

                        if fast_popup == nil then

                                    @fast_popup = false

                        else

                                    @fast_popup = fast_popup

                        end

                        

                        @a3 = WIN32OLE.new("AutoItX3.Control")

                        @a3.AutoItSetOption("WinTitleMatchMode", 2)
# set window recognition to "match any substring in the title"

                        

                        @max_wait = 120

                        

            end

            

            attr_reader :max_wait

            attr_writer :max_wait

            

            # 02/16/06 KL:  u need to pass a block along with your call
to click_ctl.

            # the associated block should specify the action taken to
generate the popup you want

            # to interact with.  the block can also be empty.

                        

            def click_ctl(ctl_id)

                        

                        if @fast_popup then

                        

                                    cmd = "ruby
c:/regression_tests/common/script/popup_click_ctl.rb \"#{@win_title}\"
\"#{ctl_id}\""

                                    

                                    t = Thread.new() {

                                                system(cmd)

                                    }

                                    

                                    m = Thread.new() {

                                                yield

                                    }

                                    

                                    

                                    m.join

                                    t.join

                                                            

                        else

                                    

                                    yield

                                    sleep(2)


                                    @a3.WinWait(@win_title, "",
@max_wait)

                                    if @a3.WinExists(@win_title, "") ==
1 then

 
@a3.WinActivate(@ie.title()) if @ie

 
@a3.WinActivate(@win_title)

 
@a3.ControlClick(@win_title, "", ctl_id)

                                    end

                                    

                        end

                        

                        # return focus to the browser.

                        @ie.focus if @ie

 

            end

end

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20060807/e352d8d9/attachment.html 


More information about the Wtr-general mailing list