Hi,

While searching for the popup handling options in Watir I found out
the below script and tried using the same on the below HTML code:
Thanks to "Jarod Zhu" for the script lines.

<html>
<head>
<script type="text/javascript">
function disp_alert()
{
alert("I am an alert box!!");
}
</script>
</head>
<body>

<a href= "http://www.google.com"; onclick="disp_alert()" /> Click Here
</a>

</body>
</html>

Here popup will be activated from the link.

Where is the mistake in the below script? Script is not able to
identify the OK button which is coming on the popup.

def startClicker( ie, button , waitTime= 10, user_input=nil )
  puts # get a handle if one exists
  hwnd = ie.enabled_popup(waitTime)
  if (hwnd)
    puts    # yes there is a popup
    w = WinClicker.new
    if ( user_input )
      w.setTextValueForFileNameField( hwnd, "#{user_input}" )
    end
    puts # I put this in to see the text being input it is not
necessary to
work
    sleep 2
    puts # "OK" or whatever the name on the button is
    w.clickWindowsButton_hwnd( hwnd, "#{button}" )
    puts # this is just cleanup
    w=nil
  end
end

link = 'C:\test.html'
ie = Watir::IE.start(link)
ie.link(:text, 'Click Here').click
ie.button(:value,"OK").click_no_wait
startClicker($ie,"OK", 10)

Logs:
>ruby testPopupHandler.rb
C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/element.rb:52:in
`assert_exists': Unable to locate element, using :value,
"OK" (Watir::Exception::UnknownObjectException)
        from C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/element.rb:
284:in `enabled?'
        from C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/element.rb:
56:in `assert_enabled'
        from C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/element.rb:
220:in `click_no_wait'
        from testPopupHandler.rb:31
>Exit code: 1

Please help.

Thanks,
Jaggi

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to