0

有沒有辦法強制編碼的UI測試生成器使用它已經記錄的類? 它甚至可以在單個記錄會話中創建非常類似的類。編碼的UI測試生成器記錄類似的類,在UIMap中創建大量的類

E.g.下面生成的兩個類中的唯一區別。 我想重用代碼 - 沒有意義有這樣的重複。除了手動清理之外的任何事情?

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中新類的數量?

感謝

尤里

回答

0

嘗試將THR下面的鏈接..

http://blogs.msdn.com/b/gautamg/archive/2009/12/18/why-is-coded-ui-test-generated-code-not-a-straight-line-code.aspx

http://blogs.msdn.com/b/gautamg/archive/2009/12/21/understanding-the-code-generated-by-coded-ui-test-part-2.aspx

從上面的鏈接:

代碼生成 ,我們想出了(一些基於 收到的反饋)的指導方針是 -

Encourage reusability of the test code. This is both for productivity 

和更好的維護。 使數據定製更簡單,適用於常見場景,如Data 駕駛。 完全控制前進操作的代碼。

你總是可以手動編碼,但比錄製它要聰明得多。

相關問題