頁面中存有大量的webtable,利用getcelldata方法,需要指定行、列的index. 但若在頁面上用戶
進行操作上排序,數據排列將發生變化,下面的方法,利用嵌套字典對象來轉化,從而具有邏輯意義
表現訪問單元格的值,從而減少參考物理單元格。(數據表如附件所示:)
Dim oDataTable
Dim solarExch
Dim nRows
set ōDataTable=objIdentifyPage ("阿里助手","n").WebTable("text:=操作指南.*","index:=0").WebTable("text:=選擇.*")
Set solarExch = CreateObject("scrīpting.Dictionary")
nRows=oDataTable.rowcount
For nRow=2 to nRows
symbolKey =oDataTable.getcelldata(nRow,2)
solarExch.add symbolkey, createObject("scrīpting.Dictionary")
solarExch(symbolKey).add "quantity", oDataTable.getcelldata(nRow,3)
solarExch(symbolKey).add "price", oDataTable.getcelldata(nRow,4)
solarExch(symbolKey).add "oneprice", oDataTable.getcelldata(nRow,5)
solarExch(symbolKey).add "highprice", oDataTable.getcelldata(nRow,6)
solarExch(symbolKey).add "situation", oDataTable.getcelldata(nRow,7)
Next
msgbox solarExch("asf").item("oneprice")'顯示附土中,asf(關鍵詞)這一行,一口價的值,并不依賴當前行列的順序,即便重新排序。
msgbox solarExch("試紙").item("price")
文章來源于領測軟件測試網 http://www.kjueaiud.com/