I try to use “enabled_popup” function to catch javascript popup.
The code works well like this
*************************************************************************
def startClicker( ie, button , waitTime= 9, user_input=nil )
# get a handle if one exists
hwnd = ie.enabled_popup(waitTime)
if (hwnd) # yes there is a popup
w = WinClicker.new
if ( user_input )
w.setTextValueForFileNameField( hwnd, "#{user_input}" )
end
# I put this in to see the text being input it is not necessary to
work
sleep 3
# "OK" or whatever the name on the button is
w.clickWindowsButton_hwnd( hwnd, "#{button}" )
# this is just cleanup
w=nil
end
end
$ie = Watir::IE.start( 'test.html' )
$ie.button( :id, 'btnConfirm' ).click_no_wait
startClicker( "OK", 20)
*************************************************************************
But I found invoke "click_no_wait" will delay the popup for a while,
so I try to use "click" instead:
**************************************************************************
def startClicker
...
end
$ie = Watir::IE.start( 'test.html' )
$popup = Thread.new { startClicker($ie, "OK", 40) }
$ie.button( :id, 'btnConfirm' ).click
$popup.join
**************************************************************************
The code above will pope the javascript window, but won't click the
"OK" button.
And if I click the button( :id, 'btnConfirm' ) manually, the popup
window will be handled:
**************************************************************************
def startClicker
...
end
$ie = Watir::IE.start( 'test.html' )
$popup = Thread.new { startClicker($ie, "OK", 40) }
#$ie.button( :id, 'btnConfirm' ).click # click the button manually
$popup.join
**************************************************************************
Does anyone know the reason?
Thank you
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines:
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---