# Dialog button doesn't work

**URL:** <https://www.ruby-forum.com/t/dialog-button-doesnt-work/130356>\
**Category:** Ruby\
**Created:** [February 27, 2008, 4:11pm UTC](https://www.ruby-forum.com/t/dialog-button-doesnt-work/130356 "2008-02-27T16:11:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mirth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@mirth](https://www.ruby-forum.com/u/mirth)\
**Post date:** [February 27, 2008, 4:11pm UTC](https://www.ruby-forum.com/t/dialog-button-doesnt-work/130356/1 "2008-02-27T16:11:03Z")

</div>

Hi guys,

I’m using watir to do some tests. During the test, an alert window  
will pop up. When it pops up, I will click the “OK” button on the  
dialog so that the test will continue. So I have below code to check  
the dialog exists and click the OK button:

if dialog.exists?  
puts “found the popups”  
dialog.button(‘OK’).click  
puts “suppose to kill the popups”  
end

For some unknown reasons, sometimes, the same alert window will  
disppear after clicking OK button sometimes the click doesn’t seem to  
work. But the two print statements always work.

Then I tried to use

autoit = WIN32OLE.new(‘AutoItX3.Control’)  
if dialog.exists?  
puts "found role pop ups "  
autoit.Send(’{enter}’)  
puts “suppose to kill the popups”  
end

The same happens. Two print statements always work but the alert  
window sometimes doesn’t go away.

Could anyone tell me if I’ve done something wrong? I just can’t figure  
out so any help is appreciated.

Thanks!
