数据驱动的编码UI测试搜索列表框 [英] Data-Driven Coded UI Test Search ListBox

查看:70
本文介绍了数据驱动的编码UI测试搜索列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的接受测试的应用程序将系统状态作为包含当前日期/时间和系统消息的字符串转储到列表框中.我需要在此窗口中验证大量信息.我目前正在使用移至.cs的方法.该方法使用 .包含在列表框中搜索包含预期系统输出的字符串.如果存在,则将其选中并通过测试.如果不是,则测试失败.这很慢.我的列表框最多可容纳5000个项目.下面是示例代码.是 有更好的办法吗?需要明确的是,除了字符串本身之外,我没有其他可用于窗口的列行或任何其他信息.

public void verifyTheListBox(string whatIAmLookingFor)

{

    #region变量声明

    WinWindow myWindow = new WinWindow();

    myWindow.SearchProperties [WinWindow.PropertyNames.Name] =" UINameOfParrentWindow" ;;

    WinList myList =新的WinList(myWindow);

    myList.SearchProperties [WinList.PropertyNames.Name] =" UINameOfListBox" ;;

    WinListItem myListItem =新的WinListItem(myList);

    myListItem.SearchProperties.Add(WinListItem.PropertyNames.Name,whatIAmLookingFor, >

    myListItem.SearchConfigurations.Add(SearchConfiguration.ExpandWhileSearching);

    myListItem.Select();

    #endregion

}

这很好,只是非常非常非常缓慢.我的意思是真的很慢.甚至不接近中等.像乌龟一样.一只真的,真的很慢的乌龟.谢谢:)

解决方案

我能想到的一些建议:

  • 使用WinList控件上的Items属性获取所有项目,而不是声明一个单独的WinListItem,然后搜索它们;
  • 如果您知道项目的全文(我认为如果您给它部分文本,它将起作用.您可以使用SelectedItems属性选择它们(将包含想要选择的值的数组字符串传递给它).之后,检查选择的数量 项(通过再次使用SelectedItems属性或使用SelectedIndices).如果所选项目的数量少于您的预期,则意味着缺少一个或多个值.当然,这不会告诉您哪些值(如果您执行此测试, (对于多个值),但我认为它会更快.

让我知道我的建议是否有用.



My application under test dumps system status into a list-box as a string containing the current date/time and system message. I need to verify a great deal of information in this window. I am currently using a method I moved to the .cs. The method uses .Contains to search the list-box for a string containing the expected system output. If it is there, it is selected and the test passes. If it is not, the test fails. This is quite slow. My listbox can hold as many as 5000 items. Below is example code. Is there a better way? to be clear, I have no column rows or any other information from the window to work off of other than the string itself.

public void VerifyTheListBox(string whatIAmLookingFor)

{

     #region Variable Declarations

     WinWindow myWindow = new WinWindow();

     myWindow.SearchProperties[WinWindow.PropertyNames.Name] = "UINameOfParrentWindow";

     WinList myList = new WinList(myWindow);

     myList.SearchProperties[WinList.PropertyNames.Name] = "UINameOfListBox";

     WinListItem myListItem = new WinListItem(myList);

     myListItem.SearchProperties.Add(WinListItem.PropertyNames.Name, whatIAmLookingFor,               PropertyExpressionOperator.Contains);

     myListItem.SearchConfigurations.Add(SearchConfiguration.ExpandWhileSearching);

     myListItem.Select();

     #endregion

}

This works quite well, it is just very, very, very, very, very slow. I mean really slow. Not even close to moderate. Like a turtle. A really, really slow turtle. Thanks :)

解决方案

A few suggestions that I can think of:

  • get all the items using the Items property on the WinList control, instead of declaring a separate WinListItem, and search through them;
  • if you know the full text of the items (I don't think it works if you give it the partial text) you can select them using the SelectedItems property (pass it an array string containing the values you want selected). After that, check the number of selected items (by using the SelectedItems property again, or by using SelectedIndices). If the number of selected items is lower than what you were expecting that means one or more values are missing. Of course, this doesn't tell you which values (if you do this test for multiple values), but I think it will be faster.

Let me know if my suggestions were any good.



这篇关于数据驱动的编码UI测试搜索列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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