FindMatchingControls问题 [英] FindMatchingControls issue

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

问题描述

嗨。

根据:

- http://blogs.msdn.com/b/balagans/archive/ 2009/12/28 / 9941582.aspx:"如果使用SearchProperties的搜索结果只找到一个控件或者找不到任何控件,编码的UI测试会跳过使用过滤器属性(即使是
,如果在代码中定义)因为2个案例"

- http://blogs.msdn.com/b/balagans/archive/2009/12/28/9941582.aspx: "In cases, where the results of the search using SearchProperties finds exactly one control or doesn’t find any control, Coded UI test skips using the Filter Properties (even if is defined in the code) because of the 2 cases"

- 以及后来:http://social.msdn.microsoft.com/Forums/en-US/vsautotest/thread/253ca535 -08f5-4b1d-9c1b-4c86795efe67;

- and later: http://social.msdn.microsoft.com/Forums/en-US/vsautotest/thread/253ca535-08f5-4b1d-9c1b-4c86795efe67;

如果我为对象定义了一些搜索属性,并且在运行期间页面中没有具有特定属性的对象,我不应该收到任何结果。

if I define some search properties for an object and during the run time there is no object in the page with the specific properties, i shouldn't receive any results.

但它似乎不是那样的。我们来举个例子吧。使用"www.google.com"和:

But it seems that it is not working like that. Let's take an example. Use "www.google.com" and:

BrowserWindow browser = new BrowserWindow();

browser.SearchProperties.Add(" Class"," IEFrame");


HtmlImage image = new HtmlImage(browser);

image.SearchProperties [HtmlImage.PropertyNames.Id] =" TGS_h_butSearch" ;;
$
if(image.FindMatchingControls ()。计数== 0)

{

Console.WriteLine("错误。无对象");

}

else

{

Console.WriteLine(" Found {0} objects",image.FindMatchingControls()。Count);

}

BrowserWindow browser = new BrowserWindow();
browser.SearchProperties.Add("Class", "IEFrame");
HtmlImage image = new HtmlImage(browser);
image.SearchProperties[HtmlImage.PropertyNames.Id] = "TGS_h_butSearch";
if (image.FindMatchingControls().Count == 0)
{
Console.WriteLine("Error. No object");
}
else
{
Console.WriteLine("Found {0} objects", image.FindMatchingControls().Count);
}

如果我运行代码,我将得到结果(即使没有具有该Id属性的对象 - 没有定义过滤器属性 - ,它正在搜索页面中的所有图像)。但是,如果我要添加:

If i run the code i will have results (even there are no object with that Id property - no filter properties defined - , it's searching for all images from page). But if I'm adding:

            image.SearchProperties.Clear();

            image.FilterProperties.Clear();

            image.SearchProperties.Clear();
            image.FilterProperties.Clear();

- 在我添加Id属性的行之前 - 它工作正常(我没有搜索结果)。

- before the line where i add the Id property - it's working fine (I don't have search results).

在添加新的之前,我需要使用Clear来清除SearchProeprties和FilterProperties。建筑师也一样。如果我正在删除过滤器属性,请在我尝试查看
页面中有多少控件时重新生成设计器文件,如果我在错误的页面中,我将收到错误的结果数量(相反,我将收到与我的对象具有相同类型的对象的总数。)

It's seems that, i need to use Clear to clear SearchProeprties adn FilterProperties, before adding new ones. The same for builder. If I'm deleting the filter properties, regenerate the designer file when I'm trying to see how many controls i have in the page, if I am in a wrong page, i will receive a wrong number of results (instead 0 i will receive the total number of the object with the same type as my object).

为什么我应该在添加新方法之前使用Clear方法清除所有SearchProperties和FilterProperties? 

Why should i use Clear method to clear all SearchProperties and FilterProperties before adding new ones? 

更多,如果我不使用Clear并且我试图检查对象是否存在(使用Exist),我会收到错误的答案(true而不是false)。这应该是怎么回事?如果是,为什么?在这种情况下,我可以在哪里获得更多资源(搜索/查找算法)?

More, if i don't use Clear and I'm trying to check if the object exist (with Exist), i receive a wrong answer (true instead of false). This is how it is supposed to be? If yes, why? And in this case, where can I more resources about that (search/find algorithm)?

 

 

推荐答案

感谢您报告此事。这看起来像FindMatchingControls()逻辑中的一个错误。
Thanks for reporting this. This looks like a bug in the FindMatchingControls() logic.


这篇关于FindMatchingControls问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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