Security Alert pop-up code is not working at all

16 views
Skip to first unread message

Dheeraj Gambhir

unread,
Jul 20, 2009, 5:34:25 AM7/20/09
to Watir General
I am automating ssl certified site.(https) whenever i goto the login
page it throws me a security alert popup, i am not able to close that
popup using watir. how can i control that , can you please help me,
right now i am using
watir1.6.2
ruby 1.8.6 -26

Thanks in advance :)

Željko Filipin

unread,
Jul 20, 2009, 5:46:37 AM7/20/09
to watir-...@googlegroups.com
On Mon, Jul 20, 2009 at 11:34 AM, Dheeraj Gambhir <checktest...@gmail.com> wrote:
> whenever i goto the login
> page it throws me a security alert popup

Take a look:

http://wiki.openqa.org/display/WTR/Pop+Ups
http://wiki.openqa.org/display/WTR/Security+Alerts

Željko
--
http://watirpodcast.com/

Dheeraj Gambhir

unread,
Jul 20, 2009, 6:58:07 AM7/20/09
to Watir General
It is not working yet, i have tried all the given below methods in
code:
**********************************
require 'rubygems'
require 'watir'
require 'win32ole'


ie = Watir::IE.new
ie.goto('http://qa2.mlb.com/enterworkflow.do?
flowId=sb_purchase&brand=cle_scoreboard&wfClub=cle')
puts "Security Alert must be in the way. Click to bypass"
autoit.WinActivate( "Security Alert", "")
autoit.Send( "(TAB)")
autoit.Send( "(TAB)")
autoit.Send( "(Enter)")

autoit.ControlClick("Microsoft Internet Explorer",'', 'OK')
autoit.ControlClick("Security Information",'', '&Yes')
autoit.ControlClick("Security Alert",'', '&Yes')
sleep(5)

**********************************


#------------------------------------------------------------------------------------------------------------
#
#includes
require 'watir' # the controller
require 'win32ole'
# set a variable
test_site = 'http://qa2.mlb.com/enterworkflow.do?
flowId=sb_purchase&brand=cle_scoreboard&wfClub=cle'

# open the IE browser
ie = Watir::IE.new

# print some comments
puts "## Beginning of test: Form Submission"
puts " "

puts "Step 1: go to the test site: " + test_site
a = Thread.new {
ie.goto(test_site)
}
ie.send_keys('{TAB}')
ie.send_keys('{TAB}')
ie.send_keys('{ENTER}')
a.join
puts " Action: entered " + test_site + " in the address bar."
puts " "
puts "Step 2: enter 'dheeraj...@tavant.com' in the
emailAddress text field"
ie.text_field(:name, "emailAddress").set
("dheeraj...@tavant.com")
puts " Action: entered dheeraj...@tavant.com in the
emailAddress field"
puts " "
puts "Step 3: enter 'dheeraj' in the password text field"
ie.text_field(:name, "password").set("dheeraj")
puts " Action: entered dheeraj in the password field"
puts " "
puts "Step 4: click the 'Login' button"
ie.button(:value, "Login").click
puts " Action: clicked the Login button."
if ie.contains_text("September")
puts "Test Passed. Found the test string: 'September'. Actual
Results match Expected Results."
else
puts "Test Failed! Could not find: 'September'"
end

puts " "
ie.link(:text, "September").click



***************************************



On Jul 20, 2:46 pm, Željko Filipin <zeljko.fili...@wa-research.ch>
wrote:
> On Mon, Jul 20, 2009 at 11:34 AM, Dheeraj Gambhir <
>

Dheeraj Gambhir

unread,
Jul 20, 2009, 7:24:16 AM7/20/09
to Watir General
I tried this also, but all in vain:

require 'rubygems'
require 'watir'
require 'win32ole'
require 'watir/ie'
require 'watir\contrib\enabled_popup'

def startClicker(button , waitTime= 9, user_input=Yes)
hwnd = $ie.enabled_popup(waitTime)
if(hwnd)
w = WinClicker.new
if(user_input)
w.setTextValueForFileNameField( hwnd, "Yes")
end
sleep 3
w.clickWindowsButton_hwnd( hwnd, "Yes" )
w=nil
end
end
ie = Watir::IE.new
ie.goto('http://qa2.mlb.com/enterworkflow.do?
flowId=sb_purchase&brand=cle_scoreboard&wfClub=cle')





It is not clicking"Yes" button of security alert pop-up.

Please help me out.


Regards
D G



On Jul 20, 3:58 pm, Dheeraj Gambhir <checktestingthi...@gmail.com>
wrote:
>    puts "Step 2: enter 'dheeraj.gamb...@tavant.com' in the
> emailAddress text field"
>    ie.text_field(:name, "emailAddress").set
> ("dheeraj.gamb...@tavant.com")
>    puts "  Action: entered dheeraj.gamb...@tavant.com in the
> >http://wiki.openqa.org/display/WTR/Pop+Upshttp://wiki.openqa.org/disp...
>
> > Željko
> > --http://watirpodcast.com/

Tony

unread,
Jul 20, 2009, 12:12:12 PM7/20/09
to Watir General
Hi Dheeraj,

Modified http://wiki.openqa.org/display/WTR/Security+Alerts to handle
these popups.
Note: you would have to change the code in ie_class.rb files for this.
No changes or extra steps is required in your testcase. The popups yes
button will be clicked automatically.

Thanks,
Tony

Dheeraj Gambhir

unread,
Jul 21, 2009, 12:51:32 AM7/21/09
to watir-...@googlegroups.com
Hi,

I tried my code by replacing goto, wait in in C:\ruby\lib\ruby\gems\1.8\gems\watir-1.6.2\lib\watir\ie-class.rb file with the code given in  http://wiki.openqa.org/display/WTR/Security+Alerts, but it is giving the following error now:

C:\Program Files\Watir\examples>ruby finalcount.rb
Launched the global pop-up handler
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/ie-class.rb:480:in `wait':
undefined local variable or method `outval' for #<Watir::IE:0x321d40c> (NameErro
r)
        from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/ie-class.rb:35
9:in `goto'
        from finalcount.rb:48


Regards
Dheeraj Gambhir

Tony

unread,
Jul 21, 2009, 2:02:50 AM7/21/09
to Watir General
Hi Dheeraj,

Forgot to add the outval variable before the begin in wait.
Have updated the code, please try changing the code again.
Let me know if you run into any other issues.

Thanks,
Tony

On Jul 21, 9:51 am, Dheeraj Gambhir <checktestingthi...@gmail.com>
wrote:
> Hi,
>
> I tried my code by replacing goto, wait in in
> C:\ruby\lib\ruby\gems\1.8\gems\watir-1.6.2\lib\watir\ie-class.rb file with
> the code given in  http://wiki.openqa.org/display/WTR/Security+Alerts, but
> it is giving the following error now:
>
> C:\Program Files\Watir\examples>ruby finalcount.rb
> Launched the global pop-up handler
> c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/ie-class.rb:480:in
> `wait':
> undefined local variable or method `outval' for #<Watir::IE:0x321d40c>
> (NameErro
> r)
>         from
> c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/ie-class.rb:35
> 9:in `goto'
>         from finalcount.rb:48
>
> Regards
> Dheeraj Gambhir
>
> On Mon, Jul 20, 2009 at 9:42 PM, Tony <ynot...@gmail.com> wrote:
>
> > Hi Dheeraj,
>
> > Modifiedhttp://wiki.openqa.org/display/WTR/Security+Alertsto handle

Dheeraj Gambhir

unread,
Jul 21, 2009, 3:02:38 AM7/21/09
to watir-...@googlegroups.com
Thanks a lot dude, u rock
Its working perfectly fine.

Regards
D G

Dheeraj Gambhir

unread,
Jul 21, 2009, 3:12:08 AM7/21/09
to watir-...@googlegroups.com
Is there any command to get text from web page like my requirement is to get order-no from thank you page.

Regards
D G

Chuck van der Linden

unread,
Jul 21, 2009, 2:14:00 PM7/21/09
to Watir General
On Jul 21, 12:12 am, Dheeraj Gambhir <checktestingthi...@gmail.com>
wrote:
> Is there any command to get text from web page like my requirement is to get
> order-no from thank you page.
>

Please search the group for an answer first, I'm pretty sure this
topic has been covered. If you dont' find an answer then please
following the posting guidelines presented on the main page for
discussions, which includes such things as:
* don't ask new questions in an unrelated thread
* tell us what you've tried, and specifically what results you got
(e.g. error details etc, not just 'it didn't work'.. tell us HOW it
didn't work)
Reply all
Reply to author
Forward
0 new messages