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 ?
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.
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);
来源:https://stackoverflow.com/questions/10848757/how-to-refresh-uimap-object-in-codedui