本文介绍了存在奇怪的行为()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 你好我有一个wpf窗口我在它上面是performin Exists(),但有趣的是函数返回true,实际上窗口仍然没有被激活而且它不在那里。你能告诉我为什么会这样吗? Bellow是代码: Hello I have a wpf window where i'm performin Exists() on it, but the interesting thing is that function returns true, in fact the window is still not activated and it is not there. Can you provide me with info why this could happen. Bellow is the code: public 静态 bool AuthenticateWindowExists() {public static bool AuthenticateWindowExists(){ XLoginWindowControls xLoginControls = 新 x LoginWindowControls (); System.Threading。XLoginWindowControls xLoginControls = new xLoginWindowControls();System.Threading. Thread 。睡眠( 5000 ); Thread.Sleep(5000); bool exists = xLoginControls.OutlookWindow.XLoginWindow.Exists; bool exists = xLoginControls.OutlookWindow.XLoginWindow.Exists; return 存在; } = ======== return exists;}======== public class X LoginWindow : WinWindow public class XLoginWindow : WinWindow { public XLoginWindow( UITestControl searchLimitContainer): public XLoginWindow(UITestControl searchLimitContainer) : base (searchLimitContainer) {base(searchLimitContainer){ #region 搜索条件 Search Criteria // this.SearchProperties [WinProperties.Window.Name] =" Login"; 这 。SearchProperties [ WpfProperties 。 窗口 .AutomationId] = " XLoginWindow" ; this.SearchProperties[WpfProperties.Window.AutomationId] = "XLoginWindow"; #endregion #endregion} 推荐答案 我看到您修改了搜索属性顶部窗口元素。那就是你评论了Name =" Login"并添加了AutomationId ="XLoginWindow"。 任何原因? Top Element搜索总是使用窗口搜索进行。所以它不了解AutomationID属性。所以你需要改用名字。 谢谢你的Siddhartha _ Hi,I see that you have modified the Search Property for the Top Window element. That is you commented Name = "Login" and added AutomationId = "XLoginWindow".Any reason for this?The Top Element search always happens using a window search. So it does not understand AutomationID property. So you need to use Name instead.ThanksSiddhartha_ 这篇关于存在奇怪的行为()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-15 02:23