珍惜现在的每一分钟,全力以赴自己的梦想。 Jump for the sun, at least you land on the moon.

QTP 9 不能识别对象的新解(原创)

上一篇 / 下一篇  2007-08-02 16:37:58 / 个人分类:测试技术

前几天,在测公司外包的时候需要批量验证数据,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}eooh

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.xxx51Testing软件测试网 I9\ ?0V j6m

问题就出在这里,确实是由于对象找不到,但是QTP在设检查点(手动添加的对象)的时候没有自动和其依赖的父对象进行关联,才导致这一问题。

}K:Yj7X)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对于此问题的解决方案如下:

Q DmZ[)Gq)f#bp0

Run 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'~0

The object is not (or not yet) displayed in the application at the time of the error.

#VLtWt lOM&U*Z0

The 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.

p2by.g$FU0

 

a}6\}4L9J E7C0

TAG: 测试技术

 

评分:0

我来说两句

Open Toolbar