QTP的description对象支持正则表达式
上一篇 /
下一篇 2009-08-07 09:20:15
今天遇到一个问题,就是在使用description的时候需要用到正则表达式。
具体情况是这样的,我希望获取一个webTable内所有的micClass为image,html id 形如"dgdRequests__ctl2_imgBtnDispose"的childObjects。
仔细观察一下html id,不难发现id是动态生成的,其中"ctl2"是与webTable的row相关,第2行id为"dgdRequests__ctl2_imgBtnDispose",而第3行id则是"dgdRequests__ctl3_imgBtnDispose",于是在写代码的时候,我们必须使用正则表达式去动态匹配所有符合条件的对象。
具体代码实例如下:
Dim des
Set des = description.Create
des("micclass").value = "Image" ‘micClass为image
des("html id").value = "dgdRequests__ctl[0-9]*_imgBtnDispose" '使用正则匹配
调试过程中我们发现QTP的description对象完全支持正则表达式,这是一个很好的方法,特别是在处理动态生成的webTable childObjects的时候。
收藏
举报
TAG: