我有可能含有多达50行,有9列的表。 不过我用的填写表中数据的代码它这么长时间。
是否有这样做的一个更快的方法? 这里是我的代码
table = $browser.div(:id => "market").table(:id => 'tableTradeIndMarket')
i = 3 + rand(1..table.rows.length-4)
table.rows[i].cells[4].select_list.select 'Buy'
table.rows[i].cells[5].select_list.select 'Market'
table.rows[i].cells[6].text_field.set ($share)
table.rows[i+1].cells[4].select_list.select 'Buy'
table.rows[i+1].cells[5].select_list.select 'Limit'
table.rows[i+1].cells[6].text_field.set ($share)
//To take out dollar sign which is found on the second column and put that value in to another column of the same row
table.rows[i+1].cells[8].text_field.set(
table.rows[i+1].cells[2].text[1..table.rows[i+1].cells[2].text.length]
)
table.rows[i+1].cells[9].select_list.select 'Day'
table.rows[i+2].cells[4].select_list.select 'Buy'
table.rows[i+2].cells[5].select_list.select 'Stop'
table.rows[i+2].cells[6].text_field.set ($share)
table.rows[i+2].cells[7].text_field.set ( table.rows[i+2].cells[2].text[1..table.rows[i+2].cells[2].text.length])
table.rows[i+2].cells[9].select_list.select 'GTC'
table.rows[i+3].cells[4].select_list.select 'Buy'
table.rows[i+3].cells[5].select_list.select 'Stop/Limit'
table.rows[i+3].cells[6].text_field.set ($share)
table.rows[i+3].cells[7].text_field.set ( table.rows[i+3].cells[2].text[1..table.rows[i+3].cells[2].text.length])
table.rows[i+3].cells[8].text_field.set ( table.rows[i+3].cells[2].text[1..table.rows[i+3].cells[2].text.length])
table.rows[i+3].cells[9].select_list.select 'Day'