前几天,在测公司外包的时候需要批量验证数据,500条数据需要一条一条验证,如果眼睛跟着检查的话......会死人的。
V.q:k;D-v"\f)xC0用QTP来检查吧,想到就做。录脚本,设参数,运行...报错!而且还是Cannot identify object。立马查看对象库,奇怪啊,对象库中有不能识别的对象,但就是无法运行通过。上网查了好多资料,基本都无效。郁闷啊...
0[q6Mfcx}"T0第二天,和同事商讨,原来她和我遇到了同样的问题,也试了好多方法,无效。51Testing软件测试网m-Z},~ VSp
第三天,怀疑自己QTP问题,之前装Build 8.2,现在卸载改装9。接着又是一阵忙活,问题依旧。哎,都是撞墙的准备了555。然后同事建议采用编辑的方式录制看看是否能通过。这点提醒了我,我怎么没想到呢,好歹我也算是写过代码的。出于习惯,在录制过后,稍微留意了下原始脚本,果然被我看出问题来,如下:
sAo&z)NQ1{0插入的检查点的脚本:51Testing软件测试网6kD
a#o
@ W3}eo oh
Browser("MS/B Express_2").Page("MS/B Express_2").WebEdit("EMail").Check CheckPoint("CompareEmail")
4\\0A(~w
U8a0插入的编辑时的脚本:51Testing软件测试网3kVY.o1}'m"q
Browser("MS/B Express_2").Window("MS/B Express -- Web Page").Page("MS/B Express").WebEdit("EMail").Set “xxx@xxx.xxx”51Testing软件测试网I9\
?0Vj6m
问题就出在这里,确实是由于对象找不到,但是QTP在设检查点(手动添加的对象)的时候没有自动和其依赖的父对象进行关联,才导致这一问题。
}K:Y j7X)f$aP-o6r6|0修改后的脚本:51Testing软件测试网BI@?Lg
Browser("MS/B Express_2").Window("MS/B Express -- Web Page").Page("MS/B Express").WebEdit("EMail").Check CheckPoint("CompareEmail")51Testing软件测试网^~H![,o+|
另外,检查点的Name应该和源对象名不同,便于后期手工检查出错数据。51Testing软件测试网j7ZN1etG
QTP Help对于此问题的解决方案如下:
QDmZ [)Gq)f#bp0Run Error: Cannot identify object51Testing软件测试网/?a8?/z,N4y#u
This error indicates that there is no object in the current view of the application that matches the descrīption saved in the object repository for the object.51Testing软件测试网 G6rU2U#o2`F-Y
This error occurs in one of two basic situations:
]g[N:k`H'~0The object is not (or not yet) displayed in the application at the time of the error.
#VLtWt lOM&U*Z0The object is present, but the descrīption in your application has changed so that it no longer matches the test object descrīption that QuickTest is using to identify the object.