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.tableindex,1).cellid,'Data').divid,/Container/)
prelimtable.tablesclass,'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_fieldid, /Text/).exists? # if true, this is your
cell
cell.text_fieldid, /Text/).value=formdatatypes[2]
elsif cell.text_fieldid, /Date/).exists?
cell.text_fieldid, /Date/).value=formdatatypes[0]
elsif cell.text_fieldid, /Numeric/).exists?
cell.text_fieldid, /Numeric/).value=formdatatypes[1]
elsif cell.checkboxid,/Text/).exists?
cell.checkboxid,/Text/).set
elsif cell.checkboxid,/Date/).exists?
cell.checkboxid,/Date/).set
elsif cell.checkboxid,/Numeric/).exists?
cell.checkboxid,/Numeric/).set
elsif cell.radioid,/Text/).exists?
cell.radioid,/Text/).set
elsif cell.radioid,/Date/).exists?
cell.radioid,/Date/).set
elsif cell.radioid,/Numeric/).exists?
cell.radioid,/Numeric/).set
elsif cell.selectid,/Text/).exists?
selecttext=cell.selectid,/Text/).getAllContents()
cell.selectid,/Text/).set(selecttext[rand(selecttext.length)])
elsif cell.selectid,/Date/).exists?
selecttext=cell.selectid,/Date/).getAllContents()
cell.selectid,/Date/).set(selecttext[rand(selecttext.length)])
elsif cell.selectid,/Numeric/).exists?
selecttext=cell.selectid,/Numeric/).getAllContents()
cell.selectid,/Numeric/).set(selecttext[rand(selecttext.length)])
end
end
end
end
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.tableindex,1).cellid,'Data').divid,/Container/)
prelimtable.tablesclass,'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_fieldid, /Text/).exists? # if true, this is your
cell
cell.text_fieldid, /Text/).value=formdatatypes[2]
elsif cell.text_fieldid, /Date/).exists?
cell.text_fieldid, /Date/).value=formdatatypes[0]
elsif cell.text_fieldid, /Numeric/).exists?
cell.text_fieldid, /Numeric/).value=formdatatypes[1]
elsif cell.checkboxid,/Text/).exists?
cell.checkboxid,/Text/).set
elsif cell.checkboxid,/Date/).exists?
cell.checkboxid,/Date/).set
elsif cell.checkboxid,/Numeric/).exists?
cell.checkboxid,/Numeric/).set
elsif cell.radioid,/Text/).exists?
cell.radioid,/Text/).set
elsif cell.radioid,/Date/).exists?
cell.radioid,/Date/).set
elsif cell.radioid,/Numeric/).exists?
cell.radioid,/Numeric/).set
elsif cell.selectid,/Text/).exists?
selecttext=cell.selectid,/Text/).getAllContents()
cell.selectid,/Text/).set(selecttext[rand(selecttext.length)])
elsif cell.selectid,/Date/).exists?
selecttext=cell.selectid,/Date/).getAllContents()
cell.selectid,/Date/).set(selecttext[rand(selecttext.length)])
elsif cell.selectid,/Numeric/).exists?
selecttext=cell.selectid,/Numeric/).getAllContents()
cell.selectid,/Numeric/).set(selecttext[rand(selecttext.length)])
end
end
end
end