2011-01-12 23 views
1

下面這段代碼將在TestComplete自動化工具腳本中單擊1到9(靜態數字範圍)中的計算器按鈕。我想增強這個循環,使其點擊任何數字組合,如456或987的任意數字組合。有人能幫助我嗎?如何增強for循環來點擊任意隨機計算器數字?

//Click Calculator buttons 1-9 
for (i=1; i<=9; i++) 
{ 
    alias.Window("Button", i).ClickButton(); 
} 

回答

1

試試這個代碼:

intStartIndex = 0; 
    intEndIndex = 9; 
    // Click three buttons 
    for (i=1; i <= 3; i++) 
    { 
    btnIndex = Math.ceil(Math.random() * (intEndIndex - intStartIndex) + intStartIndex); 
    alias.Window("Button", btnIndex.toString()).ClickButton(); 
    } 
+0

嗨亞歷克斯,這是工作精絕。很多謝謝 – Karthik 2011-01-12 14:00:03