Watir-Classic does not close Javascript Dialog when button onclick event fired

124 views
Skip to first unread message

enroxorz

unread,
Sep 30, 2012, 12:27:07 PM9/30/12
to watir-...@googlegroups.com
When I do the following, the Javascript Dialog does not close (in fact, the button click is stuck and does not go any further). Is there a work around?

irb(main):001:0> require 'watir-classic'
irb(main):002:0> b = Watir::Browser.new
irb(main):003:0> b.goto 'file:///c:/test.html'
irb(main):004:0> b.button(:value => "Press").click

Watir 3.2.0
Ruby 1.9.3
test.html
Ctest.png

Jarmo Pertman

unread,
Sep 30, 2012, 12:49:07 PM9/30/12
to watir-...@googlegroups.com
Yes, you should use #click_no_wait together with Watir Alert API (http://watirwebdriver.com/javascript-dialogs/)

In your case:
require 'watir-classic'
b = Watir::Browser.new
b.goto 'file:///c:/test.html'
b.button(:value => "Press").click_no_wait
b.alert.ok

Jarmo Pertman
-----
IT does really matter - http://itreallymatters.net

enroxorz

unread,
Sep 30, 2012, 2:58:34 PM9/30/12
to watir-...@googlegroups.com
Thank you so much Jarmo. It works! You are a life saver...
Reply all
Reply to author
Forward
0 new messages