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?
end
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
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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.