如何在CodedUI中刷新UIMap对象 [英] How to refresh UIMap object in CodedUI

查看:61
本文介绍了如何在CodedUI中刷新UIMap对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以刷新UIMap对象吗? 问题是我更改了UI元素的位置,然后再次尝试获取AutomationElement,但是那时BoundingRectanle是无穷大. 因此,我假设它没有刷新UIMap对象.

Can i refresh UIMap object ? Problem is I change the location of UI element on and I again try to get the AutomationElement at that time I get AutomationELment but its BoundingRectanle is infinity. So i am assuming that it is not refreshing the UIMap object.

有人可以帮我吗?

推荐答案

在测试的UIMaps部分中,您可能会遇到类似这样的情况:

In the UIMaps section of your test, you have probably something like:

private MyTestUIMap uiMap;
public MyTestUImap UIMap
{
    get
    {
        if (this.uiMap == null)
        {
            this.uiMap = new MyTestUIMap();
        }
        return this.uiMap;
    }
}

这在第一次使用UIMap对象时为其创建一个单例.要刷新它,可以将uiMap对象设置为null,以便下次使用该对象时再次将其重新初始化:

This creates a singleton for the UIMap object the first time it is used. To refresh it, you can make set the uiMap object to null, so it gets reinitialized again when it is used the next time:

public void RefreshUIMap() 
{
    this.uiMap = null;
}

每当您要刷新UIMap(为其添加新实例)时,请调用此RefreshUIMap方法.

Whenever you want to refresh the UIMap (get a new instance to it) call this RefreshUIMap method.

编辑:
再次阅读您的问题后,我认为您想刷新UIMap中的单个Object而不是UIMap对象实例.在MyTestUIMap.uitest中选择对象(假设已安装FeaturePack 2),从对象属性中选择Search Configuration并添加配置AlwaysSearch.每当脚本中使用该对象时,testrunner都会在屏幕上再次搜索该对象,而不是尝试从缓冲区中获取它.

EDIT:
After reading your question again, I think you want to refresh a single Object in the UIMap and not the UIMap object instance. Select the object in the MyTestUIMap.uitest (assuming you have FeaturePack 2 installed), select Search Configuration from the object properties and add the configuration AlwaysSearch. Whenever the object is used in your script, the testrunner will search for it again on the screen instead of trying to get it from the buffer.

这篇关于如何在CodedUI中刷新UIMap对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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