QTP的3类顺序标识(Ordinal Identifiers)

发表于:2010-5-27 10:57

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:Testing_is_believing    来源:51Testing软件测试网采编

  对于顺序标识(Ordinal Identifiers),QTP的帮助文档是这样说的:

  An ordinal identifier assigns a numerical value to a test object that indicates its order or location relative to other objects with an otherwise identical description (objects that have the same values for all properties). This ordered value provides a backup mechanism that enables QuickTest to create a unique description to recognize an object when the defined properties are not sufficient to do so.

  总共有3类这样的顺序标识(Ordinal Identifiers):Location, Index 和 CreationTime

  其中CreationTime仅适用于Browser对象。

  顺序标识(Ordinal Identifiers)通常在描述性编程时使用。

  例1:location(location顺序标识是用上到下进行的)

'Text Box 1
Browser("title:=.*Descriptive.*").Page("micclass:=Page").WebEdit("name:=dpTest","location:=0").Set "1"
 
'Text Box 3
Browser("title:=.*Descriptive.*").Page("micclass:=Page").WebEdit("name:=dpTest","location:=1").Set "2"
 
'Text Box 2
Browser("title:=.*Descriptive.*").Page("micclass:=Page").WebEdit("name:=dpTest","location:=2").Set "3"
 
'Text Box 4
Browser("title:=.*Descriptive.*").Page("micclass:=Page").WebEdit("name:=dpTest","location:=3").Set "4"

  例2:index(index顺序标识是从左到右进行的)

'Text Box 1
Browser("title:=.*Descriptive.*").Page("micclass:=Page").WebEdit("name:=dpTest", "index:=0").Set "1"
 
'Text Box 2
Browser("title:=.*Descriptive.*").Page("micclass:=Page").WebEdit("name:=dpTest", "index:=1").Set "2"
 
'Text Box 3
Browser("title:=.*Descriptive.*").Page("micclass:=Page").WebEdit("name:=dpTest", "index:=2").Set "3"
 
'Text Box 4
Browser("title:=.*Descriptive.*").Page("micclass:=Page").WebEdit("name:=dpTest", "index:=3").Set "4"

  例3:CreationTime(仅对浏览器对象生效,按对象产生时间先后顺序排列)

SystemUtil.Run "iexplore.exe", "http://www.HP.com"            'CreationTime 0
SystemUtil.Run "iexplore.exe", "http://www.AdvancedQTP.com"   'CreationTime 1
SystemUtil.Run "iexplore.exe", "http://www.LinkedIn.com"      'CreationTime 2
 
Browser( "creationtime:=" ).Highlight     'Highlight HP.com
Browser( "creationtime:=1" ).Highlight    'Highlight AdvancedQTP.com
Browser( "creationtime:=2" ).Highlight    'Highlight LinkedIn.com

《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号