I'm new in Coded UI test, so here's a "simple" question:
Trying to navigate through the options of a menu, i've recorded actions nad tried to playback. I got the following message: The playback failed to find the control with the given search properties
Here's the code generated by recording tool:
public void NavegarSituacao()
{
#region Variable Declarations
HtmlCustom uINotíciasCustom = this.UIHttpcmshomepsafecomIWindow.UIHttpcmshomepsafecomDocument.UINotíciasCustom;
HtmlCustom uIEntretenimentoCustom = this.UIHttpcmshomepsafecomIWindow.UIHttpcmshomepsafecomDocument.UIEntretenimentoCustom;
HtmlCustom uIMulherCustom = this.UIHttpcmshomepsafecomIWindow.UIHttpcmshomepsafecomDocument.UIMulherCustom;
HtmlCustom uIEsportesCustom = this.UIHttpcmshomepsafecomIWindow.UIHttpcmshomepsafecomDocument.UIEsportesCustom;
HtmlCustom uIHomemCustom = this.UIHttpcmshomepsafecomIWindow.UIHttpcmshomepsafecomDocument.UIHomemCustom;
HtmlCustom uITecnologiaCustom = this.UIHttpcmshomepsafecomIWindow.UIHttpcmshomepsafecomDocument.UITecnologiaCustom;
HtmlCustom uIVídeosCustom = this.UIHttpcmshomepsafecomIWindow.UIHttpcmshomepsafecomDocument.UIVídeosCustom;
#endregion
// Click 'Notícias' custom control
Mouse.Click(uINotíciasCustom, new Point(89, 21));
// Click 'Entretenimento' custom control
Mouse.Click(uIEntretenimentoCustom, new Point(90, 15));
// Click 'Mulher' custom control
Mouse.Click(uIMulherCustom, new Point(90, 9));
// Click 'Esportes' custom control
Mouse.Click(uIEsportesCustom, new Point(84, 18));
// Click 'Homem' custom control
Mouse.Click(uIHomemCustom, new Point(82, 16));
// Click 'Tecnologia' custom control
Mouse.Click(uITecnologiaCustom, new Point(85, 8));
// Click 'Vídeos' custom control
Mouse.Click(uIVídeosCustom, new Point(70, 11));
}
Is there a way to catch those elements by some kind of locators(these elements doesn't have id)? Something like this:
public HtmlCustom UIHomemCustom
{
get
{
if ((this.mUIHomemCustom == null))
{
this.mUIHomemCustom = new HtmlCustom(this);
#region Search Criteria
this.mUIHomemCustom.SearchProperties["TagName"] = "LI";
this.mUIHomemCustom.SearchProperties["Id"] = null;
this.mUIHomemCustom.SearchProperties[UITestControl.PropertyNames.Name] = null;
this.mUIHomemCustom.FilterProperties["Class"] = null;
this.mUIHomemCustom.FilterProperties["ControlDefinition"] = "data-value=\"201405231131464799\"";
this.mUIHomemCustom.FilterProperties["InnerText"] = "Homem";
this.mUIHomemCustom.FilterProperties["TagInstance"] = "8";
this.mUIHomemCustom.FilterProperties["Xpath"] = "#default > div.wrapper > div.menu > div > ul > li:nth-child(5)";
this.mUIHomemCustom.WindowTitles.Add("http://cms.home.psafe.com/");
#endregion
}
return this.mUIHomemCustom;
}
}
Here's the menu: