Manish, your break is working. But it is breaking out of your code block, not your "times" loop.

{|win|
     puts "#{win.getClassName}\t#{win.getWindowText}"
     #p win.getWindowRect
     #p win
         if(win.getParent().hwnd == $ie.hwnd) then
       #p $ie.hwnd, win.getParent().hwnd
       popupwin=win
       p "Found appropriate parent...Breaking"
       break
     end
   }

If I am not mistaken, this block amounts to an "iterator controlled loop". So "break" will get you out of this block, but if you want out of your times loop, you will have to do "break break".

Lonny Eachus
==========

Subject:
[Wtr-general] not exactly watir but a ruby question
From:
Manish Sapariya <[EMAIL PROTECTED]>
Date:
Fri, 11 Aug 2006 15:28:36 +0530

Hi,
How do break out of x.times loop.

10.times do
     findWindowLike(nil, /^Microsoft Internet Explorer$/, //) {|win|
     puts "#{win.getClassName}\t#{win.getWindowText}"
     #p win.getWindowRect
     #p win
         if(win.getParent().hwnd == $ie.hwnd) then
       #p $ie.hwnd, win.getParent().hwnd
       popupwin=win
       p "Found appropriate parent...Breaking"
       break
     end
   }
   p "Waiting for one sec for diaog to show up"
   sleep 1
   end

My break in the if condition, when I find if the child is indeed the
child of my ie window, is not working as expected.

Is this correct ruby usage?
Can anyone suggest any other way to retry my waiting mechanism or the
child dialog to appear which is spawned by my IE browser.

Thanks and Regards,
Manish
_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to