Yeah, I had this exact problem and I got it working when I down-graded
to 1.8.6-26 (http://rubyforge.org/frs/download.php/29263/
ruby186-26.exe)

Here's the code I used to always check for a popup anywhere in my
script:

#Function to Close Javascript Popups When they Occur
def jsClicker( button="OK", waitTime=0)
  loop do
    begin
      hwnd = $win.enabled_popup(waitTime)
      if (hwnd)  # yes there is a popup
        w = WinClicker.new
        w.clickWindowsButton_hwnd( hwnd, "#{button}" )
        w=nil
        $popup = true
      end
    rescue
    end
  end
end

def popup_check(results)
  if($popup)
    $popup = false
    return "Javascript Popup occurred during test"
  else
    return "Javascript Popup did not occur during test"
  end
end

I use that global variable to keep track of them when they showed up
and automatically click "OK", and called popup_check() at the end of
every test so I could pass/fail it based on whether or not I expected
a popup. I created a thread at the beginning of the program that just
went off and did its thing:
$sc = Thread.new{jsClicker("OK",0)}
$popup = false

Then you just need to make sure all your clicks that you think might
have a popup are "click_no_wait"s. Also, I found that something I was
defining as a button and using click on, I had to redefine as an image
(it was an image, but I could call it a button and click would work)
for "click_no_wait" to fire correctly on it.

If you want to not have it run continuously, then take out the loop in
"jsClicker()" and just call it with a wait time of a few seconds after
your click_no_wait call.

Hope this helps!

-Dylan

On Jul 16, 8:19 am, Smruti Ranjan Kar <smrutiranjan....@gmail.com>
wrote:
> Hi Charley,
>
> I'm using ruby186-27_rc2
>
> C:\Documents and Settings\user>ruby -v
> ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]
>
> On Thu, Jul 16, 2009 at 7:58 PM, Charley Baker <charley.ba...@gmail.com>wrote:
>
> > Try click! instead of click_no_wait, which specific version of Ruby are you
> > using, the latest one click 1.8.6rc2? What does ruby -v give you? There is a
> > problem with that installer if that's the one you used where command line
> > arguments don't get quoted correctly.
>
> > Charley Baker
> > blog:http://blog.charleybaker.org/
> > Lead Developer, Watir,http://wtr.rubyforge.org
> > QA Architect, Gap Inc Direct
>
> > On Thu, Jul 16, 2009 at 10:20 AM, Smruti <smrutiranjan....@gmail.com>wrote:
>
> >> Hello,
>
> >> I have been trying to automate a requirement, that is like
>
> >> -> When I click on a link on the page, a popup should open up
> >> -> I have to verify if the pop up opened and if the text in the pop up
> >> is correct
> >> -> Click 'OK' on the pop up and move on.
>
> >> I have tried the suggestions at
> >>http://wiki.openqa.org/display/WTR/JavaScript+Pop+Ups
> >> , but they did not work. I tried with AutoIt as well as watir/contrib/
> >> enabled_popup.
>
> >> My observations are
> >> 1. If I click the button using, 'click', the pop up remains open and
> >> the script does not move forward. So, the script written after do not
> >> get executed. But if I run from IRB it works fine.
> >> 2. If I click the button using 'click_no_wait', the pop up gets closed
> >> immediately and the following scripts do not find the pop up.
>
> >> XP SP2
> >> Ruby 1.8
> >> Watir 1.6.2
> >> IE
>
> >> Please, suggest.
--~--~---------~--~----~------------~-------~--~----~
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 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to