QTP遍歷頁面對象以及強制退出循環 軟件測試
遍歷頁面對象前先要找到需要遍歷對象的總數,可以使用多種方法,比如getElementById(),is noting,exist等等。相對更簡單的辦法是object.count。實例如下
counter=MychildObject.count /獲取某個特定對象的數量
For counter = 0 to counter-1 for循環從0到counter-1
MyChildObject(counter).Click 點擊counter次
Next
遍歷對象的過程中如果需要強制退出for循環,可以使用exit for
counter=MychildObject.count /獲取某個特定對象的數量
counter2=MychildObject2.count /獲取另一對象的數量
For counter = 0 to counter-1 for循環從0到counter-1
MyChildObject(counter).Click 點擊counter次
If counter2=1 then /當counter2為2時,執行對象2的點擊
MyChildObject2(0).Click
exit for /退出循環
end if
Next
文章來源于領測軟件測試網 http://www.kjueaiud.com/