# Modal dialog is not geting closed second time in RUBY:WATIR

**URL:** <https://www.ruby-forum.com/t/modal-dialog-is-not-geting-closed-second-time-in-ruby-watir/113924>\
**Category:** Ruby\
**Created:** [September 6, 2007, 7:49am UTC](https://www.ruby-forum.com/t/modal-dialog-is-not-geting-closed-second-time-in-ruby-watir/113924 "2007-09-06T07:49:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chetanpatil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b38774/32.png) [@chetanpatil](https://www.ruby-forum.com/u/chetanpatil)\
**Post date:** [September 6, 2007, 7:49am UTC](https://www.ruby-forum.com/t/modal-dialog-is-not-geting-closed-second-time-in-ruby-watir/113924/1 "2007-09-06T07:49:39Z")

</div>

model=$browser.modal\_dialog  
model.close

While closing the forst modal dialog in RUBY : WATIR we used the  
following code

model=$browser.modal\_dialog  
model.close

if we tried to close the same modal dialog second time which is present  
in another tab didn’t work.

---

<div class="post-metadata">

**Author:** ![chetanpatil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b38774/32.png) [@chetanpatil](https://www.ruby-forum.com/u/chetanpatil)\
**Post date:** [September 6, 2007, 3:53pm UTC](https://www.ruby-forum.com/t/modal-dialog-is-not-geting-closed-second-time-in-ruby-watir/113924/2 "2007-09-06T15:53:11Z")

</div>

Pretty watir specific, so maybe repost to the watir mailing list.  
The long&short of it is though, modal dialogs are a pain in waitr 😉  
I’ve always had to use winclicker for them.

If you have a link that brings up the dialog, and the link is stored  
in the variable @link, something like this should work.

def startClicker( button , waitTime = 3)  
#(copied & edited from various sources), I’d cite but I forget all  
of them 🙂  
w = WinClicker.new  
longName = @ie.dir.gsub("/" , “\” )  
shortName = w.getShortFileName(longName)  
c = "start ruby #{shortName}\watir\clickJSDialog.rb #{button}  
#{waitTime} "  
puts “Starting #{c}”  
w.winsystem©  
w=nil  
end

startClicker(“OK”)  
@link.click

–Kyle

---

<div class="post-metadata">

**Author:** ![chetanpatil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b38774/32.png) [@chetanpatil](https://www.ruby-forum.com/u/chetanpatil)\
**Post date:** [September 6, 2007, 4:12pm UTC](https://www.ruby-forum.com/t/modal-dialog-is-not-geting-closed-second-time-in-ruby-watir/113924/3 "2007-09-06T16:12:12Z")

</div>

Did I say mailing list? Yeah I did.  
Oops, not mailing list, google groups.  
[http://groups.google.com/group/watir-general/](http://groups.google.com/group/watir-general/)

–Kyle
