Error in wait method

12 views
Skip to first unread message

Idan Miller

unread,
Jan 29, 2008, 3:16:42 AM1/29/08
to Watir General
Hi everyone,

I'm using watir and I get this error in several links when trying to
go back in a page:

Caught NoMethodError: undefined method `times' for nil:NilClass
C:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/ie.rb:466:in
`wait'
C:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/ie.rb:338:in
`back'

It comes back once in a while, from what I've seen it's in the same
place.
The link html is as follows:
<A class=topblong onclick=this.blur();
href='javascript:top.buildMenu("Investments", true)'>text<BR>׳test</A>

Note that all the link methods work fine, I get the html, text etc..,
but when clicking this happens.

Anyway has any ideas why?

I'm using watir 1.5.3 and ruby 1.8.6.

Thanks,
Idan Miller

Idan Miller

unread,
Jan 29, 2008, 4:42:08 AM1/29/08
to Watir General
Correction: This happens when clicking, not only when going back.
Sepcificaly, the part that reproduces is the part when I click the
link whos html I pasted.

Željko Filipin

unread,
Jan 29, 2008, 4:49:40 AM1/29/08
to watir-...@googlegroups.com
On Jan 29, 2008 10:42 AM, Idan Miller <Idan....@gmail.com> wrote:
> Sepcificaly, the part that reproduces is the part when I click the
> link whos html I pasted.

Hi Idan,

Please post your Watir code.

Željko
--
ZeljkoFilipin.com

Idan Miller

unread,
Jan 29, 2008, 5:47:12 AM1/29/08
to Watir General
A simplification of my watir code (posting all of it will be too hard
to understand, so I tried to extract the relevant watir part):

currControl = browser.links(:index, index)

# Here comes several actions using currControl.html,
currControl.text...

framesNum = node.browser.document.frames.length
framesPages = []
if (framesNum != 0)
for frameIndex in 1..framesNum do
currFrame = node.browser.frame(:index, frameIndex)
framesPages << PageAttributes.create(currFrame)
end
end

currControl.click

# Here comes code that handles modal dialogs with modal_dialog (closes
them if they exist)... Not sure if this is relevant to the issue

On 29 ינואר, 11:49, "Željko Filipin" <zeljko.fili...@gmail.com> wrote:

Željko Filipin

unread,
Jan 29, 2008, 6:21:28 AM1/29/08
to watir-...@googlegroups.com
On Jan 29, 2008 9:16 AM, Idan Miller <Idan....@gmail.com> wrote:
> Caught NoMethodError: undefined method `times' for nil:NilClass

Browse your code for method called "times". You are calling that method on variable that contains nothing (nil). If you do not have that method, then it could be a Watir bug.

Željko

Bret Pettichord

unread,
Jan 30, 2008, 11:39:48 PM1/30/08
to watir-...@googlegroups.com
Thank you for the report. This is very clearly a bug in watir.
Specifically in line 466 if ie.rb:

while doc = documents_to_wait_for.shift
begin
until doc.readyState == "complete" do
sleep a_moment
end
@url_list << doc.url unless @url_list.include?(doc.url)
doc.frames.length.times do |n|
begin
documents_to_wait_for << doc.frames[n.to_s].document
rescue WIN32OLERuntimeError
end
end
rescue WIN32OLERuntimeError
end
end

The line with "doc.frames.length.times" is failing because
"doc.frames.length" is returning nil. I have no idea why this is
happening in your case.

We can probably patch Watir with this information alone, but if we had a
better understanding of the conditions that lead to this it would give
me more confidence.

We need to track this problem in Jira.

Bret


--
Bret Pettichord
Lead Developer, Watir, http://wtr.rubyforge.org
Blog, http://www.io.com/~wazmo/blog

Idan Miller

unread,
Jan 31, 2008, 5:12:33 AM1/31/08
to Watir General
Hi,

Thanks for the answer.
I will try to isolate a code that shows this problem more clearly.

Thanks,
Idan.
> > I'm using watir and I get thiserrorin several links when trying to
> > go back in a page:
>
> >  Caught NoMethodError: undefinedmethod`times' for nil:NilClass
> >    C:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/ie.rb:466:in
> > `wait'
> >    C:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/ie.rb:338:in
> > `back'
>
> > It comes back once in a while, from what I've seen it's in the same
> > place.
> > The link html is as follows:
> > <A class=topblong onclick=this.blur();
> > href='javascript:top.buildMenu("Investments", true)'>text<BR>׳test</A>
>
> > Note that all the link methods work fine, I get the html, text etc..,
> > but when clicking this happens.
>
> > Anyway has any ideas why?
>
> > I'm using watir 1.5.3 and ruby 1.8.6.
>
> > Thanks,
> > Idan Miller
>
> --
> Bret Pettichord
> Lead Developer, Watir,http://wtr.rubyforge.org
> Blog,http://www.io.com/~wazmo/blog-הסתר טקסט מצוטט-
>
> -הראה טקסט מצוטט-

Željko Filipin

unread,
Jan 31, 2008, 5:41:35 AM1/31/08
to watir-...@googlegroups.com
On Jan 31, 2008 5:39 AM, Bret Pettichord <br...@pettichord.com> wrote:
> We need to track this problem in Jira.

Idan,

This means you should add new ticket to Watir bug tracker, if you want it to be fixed (and not forgotten). Let me know if you need help with that.

Željko

Idan Miller

unread,
Feb 6, 2008, 4:01:10 AM2/6/08
to Watir General
Hi,

I have managed to isolate the problem.
It happens when I click a certain link, then the wait() method is
called behind the scenes.
So all I do is call the click method.

I also noticed that after the click, a screen loads in the browser,
and then a loading of some other page is started.
I assume that because the wait() is called when the browser loads
another screen it somehow loses its reference to the frames?
I have no idea what is the problem here but that is all the info I
get...

Here is the link html, it calls javascripts so I don't really know
what's going on there.
<A class=topblong onclick=this.blur();
href='javascript:top.buildMenu("Investments", true)'>׳
₪׳§׳“׳•׳ ׳•׳×<BR>׳•׳—׳¡׳›׳•׳ ׳•׳×</A>

Is that enough information to open a bug in bug tracker?
Is there an immediate fix I can apply?

Thanks,
Idan.

On 31 ינואר, 12:41, "Željko Filipin" <zeljko.fili...@gmail.com> wrote:

Željko Filipin

unread,
Feb 6, 2008, 7:59:14 AM2/6/08
to watir-...@googlegroups.com
On Feb 6, 2008 10:01 AM, Idan Miller <Idan....@gmail.com> wrote:
> Is that enough information to open a bug in bug tracker?

I think it is.

Željko
Reply all
Reply to author
Forward
0 new messages