使用编码的UI测试进行测试 [英] tests with Coded UI Tests

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

问题描述

嗨.

我们希望使用编码的UI测试进行自动化测试,并且控件识别及其属性存在一些问题.
我们使用ComponentOne控件,例如,工具栏按钮由文本"属性识别.
由于这不是唯一的标识符,因此如果另一个控件具有相同的文本,则自动测试可能会失败.
更改控件的文本不是解决方案,我们的应用程序很大.
我的问题是,我们如何才能制作一个适配器或其他东西以正确获得控件名称,或另一个唯一的属性?

谢谢.

Hi.

We want to make automated tests using Coded UI Tests and we have some problems with control recognising and their properties.
We use ComponentOne controls, and for example, the toolbar buttons are recognised by "Text" property.
Since this is not a unique identificator, the automated tests could fail if another control has the same text.
Changing the text of the control is not a solution, our application is quite big.
My question is, how can we make a adapter or something to get the control name properly, or another unique property?

Thank you.

推荐答案

你好

我认为没有独特的属性.甚至Name都可以相同.

但是获取Name属性有什么问题呢?如果可以获取Text,那么您也可以获取Name.
Hello

I don''t think there be a unique property. Even Names can be the same.

But what''s wrong with getting Name property? If you can get Text then you can get Name too.
foreach (Control control in this.Controls)
{
    MessageBox.Show(control.Name);
}



您可以使用标签
我更喜欢用这个:



You can use Tag
I prefer to use this:

public class ExTag
{
    public ExTag()
    {
    }

    public ExTag(object tag, Type type, string uniqueName)
    {
        this.MyType = type;
        this.Tag = tag;
        this.UniqueName = uniqueName;
    }

    public Type MyType { get; set; }
    public string UniqueName { get; set; }
    public object Tag { get; set; }
}



现在:



Now:

ExTag tag = MyTextBox.Tag =  new ExTag(null, typeof(TextBox), "textbox121");


这是因为有时您需要Tag进行其他操作.这将使您拥有一个额外的Tag.

您也可以将GUID用于UniqueName.

更改控件文本不是解决方案,我们的应用程序很大
我想您认为为所有控件设置Tag也不是解决方案,但是您有更好的主意吗?编写程序以设置应用程序的所有控件Tag.


It''s because sometimes you need Tag for other things. It will enables you to have an extra Tag.

You can use GUID for UniqueName too.

Changing the text of the control is not a solution, our application is quite big
I guess you think setting Tags for all controls is not a solution too but do you have any better idea? Write a program to set all control Tags of the application.


这篇关于使用编码的UI测试进行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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