QTP遍历页面对象以及强制退出循环

    技术2022-05-19  48

    遍历页面对象前先要找到需要遍历对象的总数,可以使用多种方法,比如getElementById(),is noting,exist等等。相对更简单的办法是object.count。实例如下

    counter=MychildObject.count /获取某个特定对象的数量For counter = 0 to counter-1  for循环从0到counter-1MyChildObject(counter).Click  点击counter次Next

    遍历对象的过程中如果需要强制退出for循环,可以使用exit forcounter=MychildObject.count /获取某个特定对象的数量counter2=MychildObject2.count /获取另一对象的数量For counter = 0 to counter-1  for循环从0到counter-1MyChildObject(counter).Click  点击counter次If counter2=1 then  /当counter2为2时,执行对象2的点击MyChildObject2(0).Clickexit for   /退出循环end ifNext


    最新回复(0)