开发者

Coded UI Test Builder records similar classes, creating numerous classes in UIMap

开发者 https://www.devze.com 2023-01-23 15:11 出处:网络
Is there a way to force Coded UI Test Builder to use it’s already recorded classes? It creates very similar classes even within single r开发者_JS百科ecording session.

Is there a way to force Coded UI Test Builder to use it’s already recorded classes? It creates very similar classes even within single r开发者_JS百科ecording session.

E.g. the only difference in URL in two classes generated below. I’d like to reuse code – no sense to have such duplications. Anything besides manual cleanup?

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
    }
 // ...

}

//And almost duplicate

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
 }
// ...
}

Thus, question is how to eliminate duplication? Any hints to decrease number of new classes in UIMap?

Thanks

Yuri


try going thr below links..

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

from above links:

The guidelines for code generation that we came up with (some based on the feedback received) was -

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

and better maintenance. Make customization of code easier for common scenarios like Data Driving. Give full control on the code for advance operation.

You can always hand code the same.but is much more tricker than recording it.

0

精彩评论

暂无评论...
验证码 换一张
取 消