【软件测试自动化-QTP NOTE 6】 == 描述性编程(Descriptive Programming)-2nd ==

上篇blog中,我大致介绍了DP的基本概念和识别对象的机制。在这次的文章中,我会延展下DP用到的方法。

 

1.还是以Google为例,不知大家是否知道Google页面中Link属性的对象到底有多少个,借此我们可以创建DP对象的方法来试试

Dim oDesc '描述对象 Dim oCol Set oDesc = Description.Create oLink("micclass").value="Link" Set oCol= Browser("title:=Google").Page("title:=Google").ChildObjects(oLink) Msgbox oCol.Count '属性为Link的对象数-大家可以看到是30个

 

2. 以上例子是用单属性来确认的,如果我想知道属性是"Link"并且text为"图像"对象数目,该如何处理呢?

Dim oDesc '描述对象 Dim oCol Set oDesc = Description.Create oDesc("micclass").value="Link" oDesc("text").value="图片" Set oCol= Browser("title:=Google").Page("title:=Google").ChildObjects(oDesc) Msgbox oCol.Count '属性为Link并且text为图片的对象数-返回为1 oCol(0).highlight '在页面高亮此对象

 

这两种方法和思想是我们经常会用到的,需要好好掌握。


 

 

你可能感兴趣的:(编程,软件测试,Google,Blog,browser)