如何使用TestComplete在桌面测试中刷新子对象



有一个桌面窗口,它有更多的选项卡,一些选项卡包括文本编辑器。编辑器按钮在第一个选项卡上有以下映射(这里进行了简化):

Window.PageControl.Tab1.Editor.Panel.Button1
Window.PageControl.Tab1.Editor.Panel.Button2 and so on.

编辑器按钮在第二个选项卡上有以下映射(这里简化了):

Window.PageControl.Tab2.Editor.Panel.Button1
Window.PageControl.Tab2.Editor.Panel.Button2 and so on.

(有时编辑器和其他对象之间的编辑器和面板缓存和他们的映射不稳定)

我写了一个测试,以以下方式检查文本编辑器的功能:

Window.PageControl.TabIndex := 1;
editor_test;
Window.PageControl.TabIndex := 2;
editor_test;

editor_test如下:

Window.PageControl.Refresh;
lprops := ['FullName','WndClass'];
lvals := ['*Panel', 'TWPToolPanel'];
ltarget := Aliases.(application name).Find(lprops,lvals,20,true);
ltarget.Button1.Click;
ltarget.Button2.Click...

editor_test可以在窗口的任何一个选项卡上正常工作。虽然,当我尝试在一个测试中多次运行editor_test时,更改选项卡后测试失败,因为它搜索前一个选项卡上的按钮。我尝试在选项卡的共同父对象上使用Refresh和RefreshMappingInfo方法(见上文),但它们没有帮助。(选项卡的名称和数量可以根据条件在窗口中更改。)

在测试运行期间是否有其他方法清除缓存的映射树?这个概念有什么错误吗?

提前感谢您的任何建议!

解决方案是以以下方式补充编辑器测试:

lprops := ['FullName','WndClass', 'VisibleOnScreen'];
lvals := ['*Panel', 'TWPToolPanel', true];

使用这个,TestComplete不能识别窗口的非活动选项卡上的编辑器按钮,这在原始场景中发生过。

最新更新