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