由Hints发现的ComboBox [英] ComboBox discovered by Hints

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

问题描述

我正在使用编码用户界面,Visual Studio 2017. 我遇到的问题是我正在测试的应用程序中的UI控件,很多都缺少自动化ID及其名称。 编码的用户界面会通过参考它看到的内容来查找控件。 这些参考文件中的一个
是在组合框上发现时所选择的项目。


所以问题是当我第一次选择组合框项目时,它的工作原理。细 但是,如果我第二次尝试选择另一个项目时它不起作用,因为原来所选的项目不再可见。


除了开发之外,有没有人知道这个的解决方法添加自动化ID或专有名称。 似乎无法修复,因为它是用于发现UI控件的项目之一。




NR

解决方案

嗨Highlander4,


欢迎来到MSDN论坛。


>>

我遇到的问题是我正在测试的应用程序中的UI控件,很多都缺少自动化ID及其名称。


您正在测试哪些应用程序?


您的意思是应用程序的ComboBox项目没有自动化ID和名称属性吗?


>>

但是,如果我第二次尝试选择另一个项目则不起作用,因为原来所选项目不再可见。


请在编码的UI测试构建器中使用十字准线来找到应用程序上的控件,然后检查其属性。请使用从断言获取的
搜索属性窗口以查找应用程序中的控件。




请参阅此示例代码来识别ComboBox项:


<预类=" prettyprint">公共无效CodedUITestMethod1()
{
ApplicationUnderTest uIMainWindowWindow1 = ApplicationUnderTest.Launch(QUOT; C:\\Users\\v-yazhu1.FAREAST\\Desktop\\TestWPF\\TestWPF\\bin\ \Debug\\TestWPF.exe");
WpfComboBox COM =新WpfComboBox(uIMainWindowWindow1);
com.SearchProperties.Add(WpfComboBox.PropertyNames.ControlType,"组合框");
com.SearchProperties.Add(WpfComboBox.PropertyNames.AutomationId,"组合框");
WpfListItem项=新WpfListItem(uIMainWindowWindow1);
item.SearchProperties.Add(WpfListItem.PropertyNames.ControlType," ; ListItem");
item.SearchProperties.Add(WpfListItem.PropertyNames.Name," Two");
com.SelectedItem = item.Name;
}

问候,


Judyzh


I'm using coded UI, Visual Studio 2017.  The problem I have is that the UI Controls in application I'm testing, many are missing Automation ID and their Names.  Coded UI makes an effort to find the controls by reference to what it sees.  One of those references is the selected item at time of discovery on a Combo Box.

SO the problem is that when I select a Combo Box item the first time, it works fine.  However, if I try to select another item the second time it doesn't work because the original selected item is not visible anymore.

Do anyone know of a workaround for this other than have development add the automation ID or proper name.  It seems impossible to fix as it is one of the items used to discover the UI control.


NR

解决方案

Hi Highlander4,

Welcome to the MSDN forum.

>> The problem I have is that the UI Controls in application I'm testing, many are missing Automation ID and their Names.

What application are you testing?

Do you mean that the application's ComboBox item does not have Automation ID and Name properties?

>> However, if I try to select another item the second time it doesn't work because the original selected item is not visible anymore.

Please use cross-hair in coded UI test builder to locate the control on application and then check its properties. Please use the Search properties that get from the Assertions window to find the control in your application.

Please refer to this sample code to identify the ComboBox item:

public void CodedUITestMethod1()
        {
            ApplicationUnderTest uIMainWindowWindow1 = ApplicationUnderTest.Launch("C:\\Users\\v-yazhu1.FAREAST\\Desktop\\TestWPF\\TestWPF\\bin\\Debug\\TestWPF.exe");
            WpfComboBox com = new WpfComboBox(uIMainWindowWindow1);
            com.SearchProperties.Add(WpfComboBox.PropertyNames.ControlType, "ComboBox");
            com.SearchProperties.Add(WpfComboBox.PropertyNames.AutomationId, "ComboBox");            
            WpfListItem item = new WpfListItem(uIMainWindowWindow1);
            item.SearchProperties.Add(WpfListItem.PropertyNames.ControlType, "ListItem");
            item.SearchProperties.Add(WpfListItem.PropertyNames.Name, "Two");
            com.SelectedItem = item.Name;
        }

Regards,

Judyzh


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

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