Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
237 views
in Technique[技术] by (71.8m points)

mstest - How to refresh UIMap object in CodedUI

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.

Can anyone please help me on this ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...