# How to handle popup dialog box

**URL:** <https://www.ruby-forum.com/t/how-to-handle-popup-dialog-box/104396>\
**Category:** Ruby\
**Created:** [May 17, 2007, 3:08pm UTC](https://www.ruby-forum.com/t/how-to-handle-popup-dialog-box/104396 "2007-05-17T15:08:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amruta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e480ec/32.png) [@amruta](https://www.ruby-forum.com/u/amruta)\
**Post date:** [May 17, 2007, 3:08pm UTC](https://www.ruby-forum.com/t/how-to-handle-popup-dialog-box/104396/1 "2007-05-17T15:08:26Z")

</div>

Hi,  
I’am new to Ruby.Please help me to get this done.  
After clicking on a button a popup dialog box appears on the  
screen.Which is a login page having Username and Password text fields  
and Ok button.I’am not able to get that dialog box and not able to set  
text values.

ie.button(:id , “Sign In”).click  
def enabled\_popup(timeout)

#popup=ie.Dialog(“title:Login”).text().to\_s  
hwnd=ie.enabled\_popup(5)  
if(hwnd)  
w=WinClicker.new  
w.makeWindowActive(hwnd)  
w.setTextBoxText(hwnd,“admin”)  
w.clickWindowsButton\_hwnd(hwnd,“Ok”)  
end  
end

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![amruta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e480ec/32.png) [@amruta](https://www.ruby-forum.com/u/amruta)\
**Post date:** [September 10, 2008, 2:05am UTC](https://www.ruby-forum.com/t/how-to-handle-popup-dialog-box/104396/2 "2008-09-10T02:05:27Z")

</div>

Hi Amruta,  
try this function

def startClicker( button , waitTime = 3)  
w = WinClicker.new  
shortName=“C:\ruby\lib\ruby\gems\1.8\gems\watir-1.5.3”  
c = "start ruby #{shortName }\watir\clickJSDialog.rb #{button }  
#{waitTime} "  
puts “Starting #{c}”  
w.winsystem©  
w=nil  
end

you just need to change the path of shortName accordingly to point to  
your clickJSDialog.rb file

good luck

Amruta wrote:

> Hi,  
> I’am new to Ruby.Please help me to get this done.  
> After clicking on a button a popup dialog box appears on the  
> screen.Which is a login page having Username and Password text fields  
> and Ok button.I’am not able to get that dialog box and not able to set  
> text values.
> 
> ie.button(:id , “Sign In”).click  
> def enabled\_popup(timeout)
> 
> #popup=ie.Dialog(“title:Login”).text().to\_s  
> hwnd=ie.enabled\_popup(5)  
> if(hwnd)  
> w=WinClicker.new  
> w.makeWindowActive(hwnd)  
> w.setTextBoxText(hwnd,“admin”)  
> w.clickWindowsButton\_hwnd(hwnd,“Ok”)  
> end  
> end
> 
> Thanks in advance.
