2012-08-27 134 views
2

我想創建帶有循環的測試用例。我獲得了最新的sideflow.js擴展,並在Selenium選項中定位到它。然後我重新啓動了Selenium IDE,但它不起作用。Selenium IDE - sideflow.js循環

樣品測試用例:

store|i|1 
while|${i}<200| 
echo|${i}| 
storeEval|i=1*storedVars['i']; i+1|i 
endWhile|| 

它顯示了以下錯誤消息:

[error] Unexpected Exception: fileName -> chrome://selenium-ide/content/tools.js -> file:///home/imslavko/bin/sideflow.js?1346044911197, lineNumber -> 100 

火狐版本:14.0.1爲Ubuntu

硒IDE版本:1.9.0

sideflow.js:最新從此頁https://github.com/darrenderidder/sideflow/blob/master/sideflow.js

如何讓它工作?提前致謝。

回答

1

如果你想創建一個循環,建議如下。我仍然在學習,所以我不確定,但這對我有效。

For i=0; i <= 200; i++ i 

break "${i}" == 200 

Echo *** "${i}" *** 

endFor 
2

而不是

store|i|1 

把它寫成

store|1|i 
0

下面是一個例子三重陣列彎針(帶靜態變量,以便可以看到它改變)

這是一個自定義的我已,注意語法用於存儲增量變量(如計數器等)

這個活套將循環所有的選項(在下面的例子中有6 * 5 * 4 = 120個選項)。它會將每個選項回顯一次,然後移至下一個選項。

example_array_looper 
storeEval new Date().getTime(); timeStart 
echo ${timeStart}  
storeEval new Array("1","2","3","4"); toparray 
storeEval new Array("A", "B", "C", "D", "E"); middlearray 
storeEval new Array("i","ii","iii","iv","v","vi"); bottomarray 
getEval topindex=0; 
getEval middleindex=0; 
getEval bottomindex=0; 
getEval loopCounter=0; 
while topindex < storedVars['toparray'].length  
storeEval topindex temptop 
while middleindex < storedVars['middlearray'].length 
storeEval middleindex tempmiddle 
while bottomindex < storedVars['bottomarray'].length 
storeEval bottomindex tempbottom 
echo javascript{storedVars['toparray'][storedVars['temptop']]+" -> "+storedVars['middlearray'][storedVars['tempmiddle']]+" -> "+storedVars['bottomarray'][storedVars['tempbottom']]} 
getEval bottomindex++; 
getEval loopCounter++; 
endWhile   
getEval bottomindex=0; 
getEval middleindex++; 
endWhile   
getEval bottomindex=0; 
getEval middleindex=0; 
getEval topindex++; 
endWhile   
storeEval loopCounter loops 
echo Total number of loops is: ${loops} 
storeEval new Date().getTime(); timeEnd 
echo ${timeEnd} 
storeEval (${timeEnd}-${timeStart})/1000 scriptRunTime 
echo Total Run Time for Script was: ${scriptRunTime}s  
storeEval ${scriptRunTime}/${loops} averageTime 
echo Average Loop Duration was: ${averageTime}s 

我選擇刪除所有的html標記(所以差距應該很明顯)。 StoreEval命令最適合保存循環計數器,因爲您可以在一步而不是2步中將它們用作增量。