Error on iterating through a set of nested tables in a form

A

Arti Singh

I am trying to run the code below on a nested table that is embedded in
a form, but I keep getting the error:

Undefined method: table for NIL class when I try to iterate through this
table.
is there anything that I am missing here.

Should I have accessed the tables in the context of the forms?









$forms=Watir::IE.new
formdatatypes=[TimeStr(),"#{rand(1000).to_s}","Hello World"]

prelimtable=$forms.table:)index,1).cell:)id,'Data').div:)id,/Container/)

prelimtable.tables:)class,'Layout').each do |t| # since you don't have
ID's, look at every table
for i in 1..t.row_count# for every row in this table
t.each do |cell|# for every column in this row, look at its
contents
if cell.text_field:)id, /Text/).exists? # if true, this is your
cell
cell.text_field:)id, /Text/).value=formdatatypes[2]
elsif cell.text_field:)id, /Date/).exists?
cell.text_field:)id, /Date/).value=formdatatypes[0]
elsif cell.text_field:)id, /Numeric/).exists?
cell.text_field:)id, /Numeric/).value=formdatatypes[1]
elsif cell.checkbox:)id,/Text/).exists?
cell.checkbox:)id,/Text/).set
elsif cell.checkbox:)id,/Date/).exists?
cell.checkbox:)id,/Date/).set
elsif cell.checkbox:)id,/Numeric/).exists?
cell.checkbox:)id,/Numeric/).set
elsif cell.radio:)id,/Text/).exists?
cell.radio:)id,/Text/).set
elsif cell.radio:)id,/Date/).exists?
cell.radio:)id,/Date/).set
elsif cell.radio:)id,/Numeric/).exists?
cell.radio:)id,/Numeric/).set
elsif cell.select:)id,/Text/).exists?
selecttext=cell.select:)id,/Text/).getAllContents()
cell.select:)id,/Text/).set(selecttext[rand(selecttext.length)])
elsif cell.select:)id,/Date/).exists?
selecttext=cell.select:)id,/Date/).getAllContents()
cell.select:)id,/Date/).set(selecttext[rand(selecttext.length)])
elsif cell.select:)id,/Numeric/).exists?
selecttext=cell.select:)id,/Numeric/).getAllContents()
cell.select:)id,/Numeric/).set(selecttext[rand(selecttext.length)])
end
end
end
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top