测试完成/执行 8 不会刷新映射信息,除非通过 COM 完成



我正在TestComplete v8中运行一个测试脚本。内存中的对象图已过期(因为出现了一个对话框)。

我运行以下VBScript代码

Sys.Process("iexplore").RefreshMappingInfo()

我收到以下错误消息。。。

Unable to find the object RefreshMappingInfo. See Additional Information for details.
The object with the specified attributes does not exist.
Possible causes of the error

此错误与TC将方法调用解释为试图查找控件有关。

真正奇怪的是。。如果我通过COM连接到TC8并执行相同的代码,它会正常工作。所以在ruby中:

require 'win32ole'
tc = WIN32OLE.connect("TestComplete.TestCompleteApplication.8")
integration = tc.integration
Sys = integration.GetObjectByName("Sys")
puts Sys.Process("iexplore").Page("http://localhost:50563/x.aspx") _
.Form("form1").Panel("silverlightControlHost").Object(0).UIAObject("Popup").Exists
' This returns false
Sys.Process("iexplore").RefreshMappingInfo()
' No error raised
puts Sys.Process("iexplore").Page("http://localhost:50563/x.aspx") _
.Form("form1").Panel("silverlightControlHost").Object(0).UIAObject("Popup").Exists
' returns true

为什么这在测试中不起作用?我该如何修复它?

TestComplete有三个对象树:

  1. Sys树,可在"对象浏览器"面板和包含所有应用程序对象
  2. NameMapping树,它包含所有映射名称
  3. 别名树,在记录测试时使用可由测试人员灵活修改

Aliases树中的对象引用NameMapping树的对象,后面的对象引用Sys中的对象。RefreshMappingInfo方法用于将存储在NameMapping树的对象中的这些引用刷新为Sys中的对象。因此,该方法仅适用于NameMappingAliases树中的对象。

在您的代码中,您使用Sys树中的一个对象:Sys.Process("iexplore")。您会收到一个错误,因为Sys树中的对象没有RefreshMappingInfo方法。您需要调用Refresh方法,或者尝试使用NameMappingAliases树中的对象。例如:

  • 系统进程("iexplore").Refresh()
  • 别名.IExplore.RefreshMappingInfo()

相关内容

最新更新