This is probably the source of your error ^^ what is being returned by
get_list_entries_container(type) may not be nil, but apparently the
class Watir::TableRow does not respond to the .length method.
retVal = 0
unless (controls.nil?)
retVal = controls.length
else
retVal = puts "Unable to find list entries for table of:
#{type}"
This seems suspicious (though unrelated to your problem). The return
value of puts is nil. Are you sure you want to actually send that to
output at that point?
···
On Fri, Mar 15, 2013 at 11:04 AM, Syed H. <lists@ruby-forum.com> wrote:
end
return retVal
end
Using gems 1.9.1 on Ruby 1.9.2 and watir-classic-3.3.0
I am unable to retrieve the list of entries from the column and get an
error
Uncaught exception: undefined method `length' for
#<Watir::TableRow:0x14b2348>
I think it lies under the get_entry_count but not quite sure, It worked
with Ruby 1.8.7
Aslo, Syed, I hope you don't mind, I'd like to offer something a
little cleaner? You can surely reject this if you want.. You may not
like early returns, which it seems your code is going out of it's way
to avoid. I think they make clearer code in some cases.
def get_entry_count(type)
return if type.nil? # you /might/ consider raising an exception if
this isn't supposed to happen?
controls = get_list_entries_container(type)
return controls.cells.count unless controls.nil?
puts "Unable to find list entries for table of type #{type}"
0
end
···
On Fri, Mar 15, 2013 at 11:04 AM, Syed H. <lists@ruby-forum.com> wrote:
def get_entry_count(type)
controls = (type.nil?)? nil : get_list_entries_container(type)
retVal = 0
unless (controls.nil?)
retVal = controls.length
else
retVal = puts "Unable to find list entries for table of:
#{type}"
end
return retVal
end
I dont mind at all I am still learning ruby and I appreciate your help
and will take the suggestion as it does look cleaner. the scenario for
this test is it goes to a certain page and tries to see if there is
something in the column if not then it moves on to adding profile. In
this case there is nothing in the table but still have to check and see
if there is something.