存在奇怪的行为() [英] Strange behavior with Exists()

查看:161
本文介绍了存在奇怪的行为()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我有一个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 < span style ="font-size:x-small; font-family:Consolas"> 静态 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 < span style ="font-size:x-small; color:#2b91af; font-family:Consolas"> < span style ="font-size:x-small; color:#2b91af; font-family:Consolas"> WinWindow

public class XLoginWindow : WinWindow

{

 

 

public XLoginWindow( UITestControl < span style ="font-size:x-small; font-family:Consolas"> 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.


Thanks
Siddhartha_


这篇关于存在奇怪的行为()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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