什么时候使用UITestControl.Find方法? [英] When would you use the UITestControl.Find method?
问题描述
在检查是否已加载页面/屏幕时,我经常使用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);
此代码有意义吗?
设置 考虑: 在上面的语句中, 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: Does this code make sense? What is the purpose of the 'Find()' calls? After setting the Consider: In the above statement the value of The 这篇关于什么时候使用UITestControl.Find方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! SearchProperties后>对于UI控件,使用code>和
FilterProperties
等, Find
方法将导致执行搜索。通常,不会显式调用 Find
,但是当UI控件在表达式中作为另一个控件的父级进行求值时,会隐式调用 Find
。 / p>
this.uimap.uiTopLevel.ActionMethod();
uiTopLevel
的值必须求值以找到可以调用 ActionMethod
的对象。该评估需要 Find
方法。
查找
当应用程序用另一个相同的副本替换其显示的一部分时,可能需要显式调用方法。 UI控件在首次评估时会获得对控件原始副本的引用。当测试尝试访问第二个版本时,它可能会出现找不到控件或隐藏控件异常(忘记这些异常的确切术语)。通过重新评估控件,即显式调用 Find
方法,可以找到控件的新版本。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);
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.this.uimap.uiTopLevel.ActionMethod();
uiTopLevel
must be evaluated to find the object whose ActionMethod
can be called. That evaluation requires the Find
method.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.