How to refresh UIMap object in CodedUI

人盡茶涼 提交于 2019-11-29 17:40:44

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;
    }
}

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;
}

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

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.

A call of the Find() method on any UITestControl should perform, or repeat, the search.

Commonly the Find() method is not called explicitly, it is called implicitly by using the control. Calling Find() on a control should re-evaluate the search and also have the effect of clearing any child controls.

BeckyN

Setting the SearchConfiguration to Always Search fixed my issue where a single control was not being refreshed with updated values causes a test to fail.

this.UIMap.UIItemWindow2.UIItemWindow11.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!