Handle Dialogbox

Hi
I am new to ruby. I am using Ruby186-27_rc2 and watir watir-1.5.3.gem.
In that i am using winclicker to handle the Dialog box. The code works
fine when i run the particulat function alone. But when i run the entire
script it is failing.
Can anyone help on this issue.
Plz find the code below:

···

============================================
def OrderInsuraceScore
if ie1.frame(:name,'MainScreen').button(:id,'cmdOrder').exists? then
ie1.frame(:name,'MainScreen').button(:id,'cmdOrder').fire_event('onclick')
ClearDialogBox()
end
ie1.frame(:name,'MainScreen').table(:index,6)[2].fire_event('onclick')
ie1.frame(:name,'MainScreen').button(:id,'cmdSelect').fire_event('onclick')
ie1.frame(:name,'MainScreen').button(:id,'cmdAccept').fire_event('onclick')
end

def ClearDialogBox
t=Thread.new(){
c=WinClicker.new
sleep(9)
han = c.getWindowHandle("Microsoft Internet Explorer")
c.clickWindowsButton_hwnd(han ,"OK")
sleep(3)
}
t.join
end
--
Posted via http://www.ruby-forum.com/.