I have figured a few things out with the click_no_wait problem.  This
potentially affects any program that uses the Ruby "system" call,
which click_no_wait does. There is also appears to be a problem with
Watir#wait_until, that is used by enabled_popup, which is used to
check for the presence of a popup.  The details follow:

First, I think the problem with click_no_wait not actually not
clicking the button/link is a Ruby 1.8.6-27 problem.  It is because
the quoted string is not passed into Ruby correctly.

On a Ruby 1.8.6-26 system, the following happens:

C:\>ruby --version
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]

C:\>ruby -e "puts \"Does this work?\""
Does this work?

C:\>

However, on a 1.8.6-27 system, the following happens:

C:\>ruby --version
ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]

C:\>ruby -e "puts \"Does this work?\""
-e:1: unterminated string meets end of file

C:\>

There is a second problem.  When you set the timeout for clicking the
popup button, Watir times out first:
.
.
.
if (ie.enabled_popup)
  wc = WinClicker.new
  wc.clickWindowsButton(/Internet Explorer/, "OK", 30)
end

>ruby javatest.rb
c:/ruby/lib/ruby/gems/1.8/gems/commonwatir-1.6.2/lib/watir/waiter.rb:
59:in `wait_until': Timed out after 4.006 seconds.
(Watir::Exception::TimeOutException)
    from c:/ruby/lib/ruby/gems/1.8/gems/commonwatir-1.6.2/lib/watir/
waiter.rb:80:in `wait_until'
    from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/contrib/
enabled_popup.rb:10:in `enabled_popup'
    from javatest.rb:13
>Exit code: 1

So even though I have the click set to not timeout until after 30
seconds, Watir seems to timeout after about 4 seconds.

There is a temporary workaround for this that works for me.  Because I
was getting the Watir timeout before the popup came up, I added a
sleep to my popupchecker method before the Timeout::timeout.  So the
first part of the popupchecker method looks like this:

def popupchecker(text)
  sleep 10
  Timeout::timeout(2) do

Note that I give this as a temporary solution until the wait_until is
fixed.

Jim

On Mar 3, 10:52 am, Jim Matthews <jim_m...@swbell.net> wrote:
> Here are the steps to reproduct the problem.  First bring up unittests
> \html\popups1.html in IE.
>
> \Ruby\lib\ruby\gems\1.8\gems\watir-1.6.2\unittests\html\popups1.html
>
> Next run this script.  I have extra "puts" in it to try to figure out
> what is going on. They can be remvoed or commented out.
>
> Jim
>
> require 'watir'
> require 'watir/ie'
> require 'watir/testcase'
> require 'watir/contrib/enabled_popup'
>
> class StepTests < Watir::TestCase
>   def test_01_step_test
>     browser = Watir::IE.attach(:title, /Test page for/)
>     browser.row(:index, 3).button(:type, 'button').click!
>     popupchecker(browser, 'OK')
>   end
>   def popupchecker(browser, text)
>     Timeout::timeout(2) do
>       begin
>         puts "Inside begin of popupcuecker."
>         puts "browser.enabled_popup == #{browser.enabled_popup}"
>         if browser.enabled_popup
>           puts "In if in popupchecker."
>           hwnd = browser.enabled_popup(5)
>           puts hwnd.to_s
>           w = WinClicker.new
>           w.makeWindowActive(hwnd)
>           w.clickWindowsButton_hwnd(hwnd, text)
>         end
>         rescue Timeout::Error
>           puts 'No popup existed.'
>       end
>     end
>   end
> end
>
> On Mar 2, 10:12 am, Jim Matthews <jim_m...@swbell.net> wrote:
>
> > I am trying to deal with javascript popups.  I have created the
> > popupchecker method described on the wiki.
>
> > When I usedclick_no_wait,  the popup came up but was not dismissed.
> > Someone suggested that I try click! instead ofclick_no_waitbecause
> > of some problems mentioned in recent posts.  I did that and click!
> > worked for the first popup.  It dismissed it and the script continued.
>
> > When the script got to the second popup, neitherclick_no_waitnor
> > click! worked to dismiss the popup.  I put some "puts" statements is
> > the popupchecker method and it appears from that, that popupchecker is
> > not getting called the second time until after I manually dismiss the
> > second popup.
>
> > I know the popupchecker code works because it successfully dismisses
> > the first popup and because I have used fxri with popupchecker to
> > dismiss both the popups.
>
> > Does anyone have an idea what is going on or something different to
> > try?
>
> > Jim
--~--~---------~--~----~------------~-------~--~----~
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