QTP下不录制脚本直接写代码 然后运行会报错 报错说在对象库中找不到对象 脚本Browser("Web Tours").Close
单独运行脚本Browser("Web Tours").Close会爆如下错误
The "Web Tours" object was not found in the Object Repository.
Check the Object Repository to confirm that the object exists or to find the correct name for the object.
但是如果先录制脚本如下:
Browser("Web Tours").Page("Web Tours").Sync
Browser("Web Tours").CloseAllTabs
然后改为
Browser("Web Tours").Close
在运行就不会报错了
是不是由于录制后把对象添加到对象库中了 在运行就能找到该对象了 而如果没有录制就不会把对象添加到对象库中 运行时就找不到对象