有没有办法强制 Coded UI Test Builder 使用它已经记录的类?即使在单个录制会话中,它也会创建非常相似的类。
例如,下面生成的两个类中 URL 的唯一区别。我想重用代码——重复这样的代码是没有意义的。除了手动清理还有什么?
public class UISearchResultsOracleDocument : HtmlDocument
{
public UISearchResultsOracleDocument(UITestControl searchLimitContainer) :
base(searchLimitContainer)
{
#region Search Criteria
this.SearchProperties[HtmlDocument.PropertyNames.Id] = null;
this.SearchProperties[HtmlDocument.PropertyNames.RedirectingPage] = "False";
this.SearchProperties[HtmlDocument.PropertyNames.FrameDocument] = "False";
this.FilterProperties[HtmlDocument.PropertyNames.Title] = "Search Results : " + EnterSearchedTextParams.UISearchEditText;
this.FilterProperties[HtmlDocument.PropertyNames.AbsolutePath] = "/project/Pages/results.aspx";
this.FilterProperties[HtmlDocument.PropertyNames.PageUrl] = "http://my.url.com:123/project/Pages/results.aspx?k=Oracle";
this.WindowTitles.Add("Search Results : Oracle");
#endregion
}
// ...
}
//而且几乎是重复的
public class UISearchResultsOracleDocument1 : HtmlDocument
{
public UISearchResultsOracleDocument1(UITestControl searchLimitContainer) :
base(searchLimitContainer)
{
#region Search Criteria
this.SearchProperties[HtmlDocument.PropertyNames.Id] = null;
this.SearchProperties[HtmlDocument.PropertyNames.RedirectingPage] = "False";
this.SearchProperties[HtmlDocument.PropertyNames.FrameDocument] = "False";
this.FilterProperties[HtmlDocument.PropertyNames.Title] = "Search Results : Oracle";
this.FilterProperties[HtmlDocument.PropertyNames.AbsolutePath] = "/project/Pages/results.aspx";
this.FilterProperties[HtmlDocument.PropertyNames.PageUrl] = "http://my.url.com:123/project/Pages/results.aspx?k=Oracle&start1=1";
this.WindowTitles.Add("Search Results : Oracle");
#endregion
}
// ...
}
因此,问题是如何消除重复?有什么提示可以减少 UIMap 中新类的数量吗?
谢谢
尤里