【软件测试自动化-QTP NOTE 5】 == 描述性编程(Descriptive Programming)-1st ==

 

描述性编程已经成为大多数自动化测试工程师在项目中更多更普遍的技术选择。对于他们来说,可以通过对象的属性来定位确认一个对象从而替代载入对象库。这对于早期自动化介入非常有帮助。

 

 

首先,我们以Google为例,用QTP自带的SPY获取搜索栏对象的属性

 

【软件测试自动化-QTP NOTE 5】 == 描述性编程(Descriptive Programming)-1st ==_第1张图片

Object Spy: Browser Properties

Browser( "title:=Google" ) 

 

 

【软件测试自动化-QTP NOTE 5】 == 描述性编程(Descriptive Programming)-1st ==_第2张图片

Object Spy: Page Properties

Page( "title:=Google" ) 

 

 

【软件测试自动化-QTP NOTE 5】 == 描述性编程(Descriptive Programming)-1st ==_第3张图片

Object Spy: WebEdit Properties

WebEdit("name:=q","html tag:=INPUT") 

 

现在我们把所有的描述组合起来:

Browser("title:=Google").Page("title:=Google").WebEdit("name:=q","html tag:=INPUT") 

其次我们可以用创建描述对象的方式对DP进行诠释:

' 创建Browser描述对象 Set oGoogBrowser = Description.Create oGoogBrowser( "title" ).value = "Google" ' 创建Page描述对象 Set oGoogPage = Description.Create oGoogPage( "title" ).Value = "Google" '创建webedit描述对象 Set oGoogWebEdit = Description.Create oGoogWebEdit( "html tag" ).Value = "INPUT" oGoogWebEdit( "name" ).Value = "q" 

得出

Browser(oGoogBrowser).Page(oGoogPage).WebEdit(oGoogWebEdit).Set "keith" 

 

 

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