Hi there, I have noticed that a script of mine seems to be having random failures that I can't explain.
I am running Watir 1.4.1 on Ruby 184-16 on Windows XP Pro SP2.
The script I'm working with walks through our site map - it enters a page, gets the page size, download time, leaves and then moves onto the next page. The script is correct.
However, at random intervals when I run it, a button or link will fail to get recognised and the script just stops. I've been trying to get around the failures by adding a "sleep 1" (or 2 or 3 seconds) whenever it fails. This latest run, it wasn't even a button that the script failed on -- it was a + operator! Okay, I know that I don't know any workaround for that one!
Here was the error output:
----
1) Error:
test_d_Reports(TC_LD_site_map_walkthru):
NoMethodError: undefined method `+' for nil:NilClass
LD_site_map_walkthrough.rb:461:in `test_d_Reports'
----
and line 461 is:
row_data[42] = row_data[42] + ',' + $ie.frame('MainWindow').html.length.to_s + ',' + $ie.down_load_time.to_s
I know there's nothing wrong with this line because it looks relatively identical to a billion other lines in the script - just the array number changes. And it works when I run it the next time.
I think the problem is that row_data[42] is nil. Are you sure it is initialized? The error message means that you are using "+" on something that is nil. It is not a Watir error.
Other errors I've seen include:
----
1) Error:
test_d_Reports(TC_LD_site_map_walkthru):
NoMethodError: undefined method `outerHTML' for nil:NilClass
----
(for the same 'row_data' kind of line as above, just elsewhere in the script.)
It helps if you can provide a stack so we know what line the problem is occuring. Different Watir objects use this call (outerHTML), but you haven't provided enough information to know which one is failing.
and errors like the following when I remove strategically inserted "sleep" lines:
----
1) Error:
test_d_Reports(TC_LD_site_map_walkthru):
NoMethodError: undefined method `all' for nil:NilClass
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:754:in `getContainerContents'
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:778:in `getObject'
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:3063:in `initialize'
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:304:in `button'
LD_site_map_walkthrough.rb:312:in `test_d_Reports'
----
for line 312: $ie.frame('MainWindow').button(:name, /CancelButton/).click
Is this something that there is a workaround for? If I had to guess, it looks like the script is trying to continue before the page itself finishes loading in IE.
This error means there is no MainWindow frame. Watir should probably be raising an UnknownFrameException here instead.
You can probably work around this problem thus:
if $ie.frame("MainWindow").exists?
$ie.frame("MainWindow").button(:name, /CancelButton/).click
else
raise, "MainWindow frame not found"
end
But in the end this only changes how the error message looks. The problem is that the frame isn't there.
Please let us know if any of these suggestions help.
Bret
_______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
