什么时候使用UITestControl.Find方法? [英] When would you use the UITestControl.Find method?

查看:80
本文介绍了什么时候使用UITestControl.Find方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在检查是否已加载页面/屏幕时,我经常使用UITestControl.WaitForControlExist()方法,但是我发现了ctl.WaitForControlExist()之后的示例代码以及对父控件的otherCtl.Find()调用。像这样:

  var选项卡= UIMainMenuExtWindow.UIItemWindow.UIRibbonClient.UISolutionsTabPage; 
选项卡.WaitForControlExist(3000);
UIMainMenuExtWindow.Find();
UIMainMenuExtWindow.UIItemWindow.Find();
UIMainMenuExtWindow.UIItemWindow.UIRibbonClient.Find();
UIMainMenuExtWindow.UIItemWindow.UIRibbonClient.UISolutionsTabPage.Find();
tab.Find();
Mouse.Click(tab);

此代码有意义吗?

解决方案

设置 SearchProperties后对于UI控件,使用code>和 FilterProperties 等, Find 方法将导致执行搜索。通常,不会显式调用 Find ,但是当UI控件在表达式中作为另一个控件的父级进行求值时,会隐式调用 Find 。 / p>

考虑:

  this.uimap.uiTopLevel.ActionMethod(); 

在上面的语句中, uiTopLevel 的值必须求值以找到可以调用 ActionMethod 的对象。该评估需要 Find 方法。



查找当应用程序用另一个相同的副本替换其显示的一部分时,可能需要显式调用方法。 UI控件在首次评估时会获得对控件原始副本的引用。当测试尝试访问第二个版本时,它可能会出现找不到控件或隐藏控件异常(忘记这些异常的确切术语)。通过重新评估控件,即显式调用 Find 方法,可以找到控件的新版本。


When checking whether a page/screen has loaded, I often use the UITestControl.WaitForControlExist() method, but I am finding example code that follows the ctl.WaitForControlExist() with otherCtl.Find() calls on the parent controls. Like this:

var tab = UIMainMenuExtWindow.UIItemWindow.UIRibbonClient.UISolutionsTabPage;
tab.WaitForControlExist(3000);
UIMainMenuExtWindow.Find();
UIMainMenuExtWindow.UIItemWindow.Find();
UIMainMenuExtWindow.UIItemWindow.UIRibbonClient.Find();
UIMainMenuExtWindow.UIItemWindow.UIRibbonClient.UISolutionsTabPage.Find();
tab.Find();
Mouse.Click(tab);

Does this code make sense? What is the purpose of the 'Find()' calls?

解决方案

After setting the SearchProperties and FilterProperties etc for a UI Control, the Find method causes the search to be performed. Commonly the Find is not called explicitly but it (or possibly some equivalent internal method) is called implicitly when the UI Control is evaluated in an expression as the parent of another control.

Consider:

this.uimap.uiTopLevel.ActionMethod();

In the above statement the value of uiTopLevel must be evaluated to find the object whose ActionMethod can be called. That evaluation requires the Find method.

The Find method may need to be called explicitly when an application replaces part of its display with another identical copy. The UI Controls, when first evaluated, get a reference to the original copy of the control. When the test tries to access the second version it may get a "control not found" or "hidden control" exception (forget the exact terminology of these exceptions). By re-evaluating the control, ie by calling the Find method explicitly, the new version of the control can be found.

这篇关于什么时候使用UITestControl.Find方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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