The automation script generated using Recording feature of CodedUI is able to find an element For Eg: a Textbox even when the ID of the textbox is changed in the Search Criteria of that element under UIMap.Designer.cs" file.
For example :
1) Suppose we have entered "ABC" in the Username textbox, the code generated for searching that textbox will be say:-
public HtmlEdit UITxtUserEdit
{
get
{
if ((this.mUITxtUserEdit == null))
{
this.mUITxtUserEdit = new HtmlEdit(this);
#region Search Criteria
this.mUITxtUserEdit.SearchProperties[HtmlEdit.PropertyNames.Id] ="txtUser";
#endregion
}
return this.mUITxtUserEdit;
}
}
2) Now if in the above code we change the Search Property value to "User" like this :-
public HtmlEdit UITxtUserEdit
{
get
{
if ((this.mUITxtUserEdit == null))
{
this.mUITxtUserEdit = new HtmlEdit(this);
#region Search Criteria
this.mUITxtUserEdit.SearchProperties[HtmlEdit.PropertyNames.Id] ="User";
#endregion
}
return this.mUITxtUserEdit;
}
}
then according to me the testcase should fail as we have changed the ID to be searched is different from the actual ID.
But the Script is not able to respond to this change and is able to find the Textbox.
For example :
1) Suppose we have entered "ABC" in the Username textbox, the code generated for searching that textbox will be say:-
public HtmlEdit UITxtUserEdit
{
get
{
if ((this.mUITxtUserEdit == null))
{
this.mUITxtUserEdit = new HtmlEdit(this);
#region Search Criteria
this.mUITxtUserEdit.SearchProperties[HtmlEdit.PropertyNames.Id] ="txtUser";
#endregion
}
return this.mUITxtUserEdit;
}
}
2) Now if in the above code we change the Search Property value to "User" like this :-
public HtmlEdit UITxtUserEdit
{
get
{
if ((this.mUITxtUserEdit == null))
{
this.mUITxtUserEdit = new HtmlEdit(this);
#region Search Criteria
this.mUITxtUserEdit.SearchProperties[HtmlEdit.PropertyNames.Id] ="User";
#endregion
}
return this.mUITxtUserEdit;
}
}
then according to me the testcase should fail as we have changed the ID to be searched is different from the actual ID.
But the Script is not able to respond to this change and is able to find the Textbox.
See this article: FAQ: Why Coded UI Test is Able to Find the Window/Controls even if the Search Properties are Different?.
ReplyDeletehttp://social.technet.microsoft.com/wiki/contents/articles/11208.visual-studio-faq-why-a-coded-ui-test-is-able-to-find-the-windowcontrols-even-if-the-search-properties-are-different.aspx