QTP OR 自动化模型:将多个对象(相同类型)添加到 QTP 对象存储库 [英] QTP OR Automation Model : Adding Multiple objects (Same type) to QTP Object Repository

查看:80
本文介绍了QTP OR 自动化模型:将多个对象(相同类型)添加到 QTP 对象存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码:

Set myRepository  = CreateObject("Mercury.ObjectRepositoryUtil")
myRepository.Load  "D:\Explore\QTP\Repositoryfff.tsr"
Set PageObj = myRepository.GetObjectByParent("Browser(""salesforce.com - Customer"")","Page(""salesforce.com - Customer"")")
Set CustomObj = CreateObject("Mercury.WebLink")
myRepository.AddObject CustomObj, PageObj, "OrderNum1"
myRepository.AddObject CustomObj, PageObj, "OrderNum2"
myRepository.Save
Set myRepository = Nothing
Set PageObj = Nothing

它不会将两个对象(OrderNum1"、OrderNum2")添加到 QTP OR,只会添加第一个对象.

It is not adding both of the objects ("OrderNum1","OrderNum2") to the QTP OR, only first one is being added.

推荐答案

问题是您添加了两次相同的对象.QTP 的对象存储库设置为在出现相同对象时重用现有对象.您应该为对象添加一些描述性属性,使其与众不同.

The problem is that you're adding the same object twice. QTP's object repository is set up to reuse existing objects if an identical object comes along. You should add some descriptive properties to the object so that it's different.

Set myRepository  = CreateObject("Mercury.ObjectRepositoryUtil")
myRepository.Load  "C:\SOR\a.tsr"
Set PageObj = myRepository.GetObjectByParent("Browser(""B"")","Page(""P"")")
Set CustomObj = CreateObject("Mercury.WebLink")
myRepository.AddObject CustomObj, PageObj, "OrderNum1"

' Make objects different
CustomObj.SetTOProperty "name", "second"

myRepository.AddObject CustomObj, PageObj, "OrderNum2"
myRepository.Save
Set myRepository = Nothing
Set PageObj = Nothing

这篇关于QTP OR 自动化模型:将多个对象(相同类型)添加到 QTP 对象存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆