The version of DL that's currently in the Ruby standard library has a
hard-coded limit of 10 callbacks.

According to this post from last summer, some fixes in WinClicker
methods were contributed to Watir 1.5, to work around this problem:

http://rubyforge.org/pipermail/wtr-general/2006-July/006828.html

..., but maybe your code is running into the same issue in some method
that hasn't been patched?  Or your winClicker.rb doesn't have those
changes for some reason?  Not sure.

You can probably fix this yourself by adding a call to
DL.remove_callback in the method (in the WinClicker class apparently)
that is causing the problem.  Once you are done using the callback,
you just pass DL.remove_callback the name of the callback that has
been defined:

======================
enum_windows_proc = DL.callback('IL') { |hwnd|
  found << hwnd
  1 # continue enumeration until all windows have been processed
}
EnumWindows.call(enum_windows_proc, 0) # Enumerate all windows
DL.remove_callback(enum_windows_proc) # Now remove the callback.
======================

Incidentally I have had to make use of #remove_callback in a
Win32::GuiTest workalike I've been slowly putting together.  I decided
to try to use Ruby DL for everything, instead of Win32API + C
extensions, so the heart of the library (the code to enumerate
windows) depends on DL.callback and DL.remove_callback. :)  So far
#remove_callback has not given me any problems at all.

Otherwise Mark's suggestion of reusing a single WinClicker object,
instead of instantiating several, is worth trying.

Thanks
Bill


On 10/27/06, George Hawthorne <[EMAIL PROTECTED]> wrote:
> Hi,
>
> The application I'm testing uses lots of modal Javascript alerts with
> 'OK' and 'Cancel' buttons. I'm using WinClicker to handle them and it
> works very nicely until you get to the 11th pop-up, at which point it
> throws the error: "DL::DLError: too many callbacks are defined." Watir
> version is 1.5.1.1119 and IE version is 7. Details are below. I'd be
> grateful for any thoughts.
>
> Here's a test that consistently produces the error. It always works
> perfectly for the first 10 instances and then fails on the 11th
> instance...
>
>    def test001
>        1.upto 20 do |i|
>          puts i.to_s
>          # add an object
>          $ie.button(:id, "addrow").click
>          # delete the object
>          $ie.button(:id, "deleterow").click_no_wait # this throws up
> a Javascript alert
>          # click OK on the pop-up
>          hwnd = $ie.enabled_popup(5)           # get a handle if one exists
>            if (hwnd)
>            w = WinClicker.new
>            w.makeWindowActive(hwnd)
>            w.clickWindowsButton_hwnd(hwnd, "OK")
>            end
>          $ie.wait
>        end
>    end
>
> Here's the output...
>
> Started
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> 10
> 11
> E
> Finished in 38.226 seconds.
>
> Thanks, George
> _______________________________________________
> Wtr-general mailing list
> Wtr-general@rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-general
>
_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to