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

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

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

前几天,在测公司外包的时候需要批量验证数据,500条数据需要一条一条验证,如果眼睛跟着检查的话......会死人的。51Testing软件测试网n$ofJE Bs J

QTP来检查吧,想到就做。录脚本,设参数,运行...报错!而且还是Cannot identify object。立马查看对象库,奇怪啊,对象库中有不能识别的对象,但就是无法运行通过。上网查了好多资料,基本都无效。郁闷啊...51Testing软件测试网@#aJ(Q;m._-v

第二天,和同事商讨,原来她和我遇到了同样的问题,也试了好多方法,无效。51Testing软件测试网A:uO3[$C'?;Y)jB|4I

第三天,怀疑自己QTP问题,之前装Build 8.2,现在卸载改装9。接着又是一阵忙活,问题依旧。哎,都是撞墙的准备了555。然后同事建议采用编辑的方式录制看看是否能通过。这点提醒了我,我怎么没想到呢,好歹我也算是写过代码的。出于习惯,在录制过后,稍微留意了下原始脚本,果然被我看出问题来,如下:

X2M{2DUl0

插入的检查点的脚本:51Testing软件测试网s$Z*ClY?uL

Browser("MS/B Express_2").Page("MS/B Express_2").WebEdit("EMail").Check CheckPoint("CompareEmail")

z GO/x|)Jh0

插入的编辑时的脚本:

7N?i UY0

Browser("MS/B Express_2").Window("MS/B Express -- Web Page").Page("MS/B Express").WebEdit("EMail").Set “xxx@xxx.xxx

ZzqswE r0

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

O ] L5|qu$He/q0{0

修改后的脚本:

^![&sJe5Iai0

Browser("MS/B Express_2").Window("MS/B Express -- Web Page").Page("MS/B Express").WebEdit("EMail").Check CheckPoint("CompareEmail")

(dZ7lj?1];NO0

另外,检查点的Name应该和源对象名不同,便于后期手工检查出错数据。51Testing软件测试网2cX![cw\

QTP Help对于此问题的解决方案如下:

^B!l6R6Zr0

Run Error: Cannot identify object

6VOggJ/{b0

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软件测试网x1rbf&K B)?'\-o

This error occurs in one of two basic situations:

L`]u@,Cm2}*V0

The object is not (or not yet) displayed in the application at the time of the error.51Testing软件测试网W_"x-xiP%k1My7]

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.

p5E-fc|0

 

VU!v%R9d[ [(MC%xV0

TAG: 测试技术

 

评分:0

我来说两句

Open Toolbar