this line was causing the problem:
this.mUIItem5Text.SearchProperties[WinText.PropertyNames.Name] = "5";
it was a redundant criteria.
Question
I am running coded ui tests on my application and i have encountered a problem:
I want to assert a label's text as it changes, but when this value changes my control becomes null (if i assert prior to changing the label's value it will be found and the assert will work).
Relevant code in my uimap (auto generated):
public void assert_labelA()
{
#region Variable Declarations
WinText uIAText = this.UIQuadraticSolverWindow.UIItem5Window.UIAText;
#endregion
Assert.AreEqual(this.assert_labelAExpectedValues.UIATextDisplayText, uIAText.DisplayText);
}
...
[GeneratedCode("Coded UITest Builder", "10.0.40219.457")]
public class UIItem5Window : WinWindow
{
public UIItem5Window(UITestControl searchLimitContainer) :
base(searchLimitContainer)
{
#region Search Criteria
this.SearchProperties[WinWindow.PropertyNames.ControlName] = "labelA";
this.WindowTitles.Add("Quadratic Solver");
#endregion
}
#region Properties
public WinText UIItem5Text
{
get
{
if ((this.mUIItem5Text == null))
{
this.mUIItem5Text = new WinText(this);
#region Search Criteria
this.mUIItem5Text.SearchProperties[WinText.PropertyNames.Name] = "5";
this.mUIItem5Text.WindowTitles.Add("Quadratic Solver");
#endregion
}
return this.mUIItem5Text;
}
}
public WinText UIAText
{
get
{
if ((this.mUIAText == null))
{
this.mUIAText = new WinText(this);
#region Search Criteria
this.mUIAText.SearchProperties[WinText.PropertyNames.Name] = "A";
this.mUIAText.WindowTitles.Add("Quadratic Solver");
#endregion
}
return this.mUIAText;
}
}
#endregion
#region Fields
private WinText mUIItem5Text;
private WinText mUIAText;
#endregion
}
Solution
this line was causing the problem:
this.mUIItem5Text.SearchProperties[WinText.PropertyNames.Name] = "5";
it was a redundant criteria.