QTP 或自动化模型:将多个对象(相同类型)添加到 QTP 对象存储库
QTP OR Automation Model : Adding Multiple objects (Same type) to QTP Object Repository
我正在使用以下代码:
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 或者,只添加了第一个。
问题是您将同一个对象添加了两次。 QTP 的对象存储库设置为在出现相同对象时重用现有对象。
您应该为对象添加一些描述性属性,使其与众不同。
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
我正在使用以下代码:
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 或者,只添加了第一个。
问题是您将同一个对象添加了两次。 QTP 的对象存储库设置为在出现相同对象时重用现有对象。 您应该为对象添加一些描述性属性,使其与众不同。
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