Question

I have been working with Coded UI Test(CUIT) feature of VS2010 .
When recording the CodedUI framework generates a lots of hierarchical classes.

I was wondering whether coding(by hand) a CUIT would reduce the code created and would it be as optimized(in searching elements) as generated code??

Also what are the scenarios where a CUIT could be coded by hand?

Was it helpful?

Solution

CUITe (Coded UI Test enhanced) Framework is for people who prefer hand coding. http://cuite.codeplex.com/

CUITe is a thin layer developed on top of Microsoft Visual Studio Team Test's Coded UI Test engine which helps reduce code, increases readability and maintainability, while also providing a bunch of cool features for the automation engineer.

CUITe allows you to define a much simpler Object Repository (== UIMap). Each page/window will be defined in a separate class file, and each UI control definition will be just a one liner. You can move common controls to a parent class which increases maintainability. You can also categorize the page/window definition classes into different folders as you deem fit.

OTHER TIPS

I have been working on Coded UI, from my understanding recorded/generated code is too complex and difficult to maintain.

I always use hand coding, which is simple and easy to maintain.

Here is full sample hand coded UI script for Silver-light application

[TestMethod]
public void SilverlightHANDCODINGTest()
{
    BrowserWindow br = BrowserWindow.Launch(@"http://localhost:1377/SilverlightApplication1TestPage.html");

    UITestControl sCustom = new UITestControl(br);
    sCustom.TechnologyName = "Web";
    sCustom.SearchProperties.Add("ControlType", "Custom");
    sCustom.SearchProperties.Add("TagName", "OBJECT");
    sCustom.SearchProperties.Add("Type", "application/x-silverlight-2");
    sCustom.SearchProperties.Add("TagName", "OBJECT");

    // sCustom.DrawHighlight();

    SilverlightControl sframe = new SilverlightControl(sCustom);
    sframe.TechnologyName = "Silverlight";
    sframe.SearchProperties.Add(SilverlightControl.PropertyNames.MaxDepth, "-1");
    sframe.DrawHighlight();

    SilverlightEdit sTextBox = new SilverlightEdit(sCustom);
    sTextBox.TechnologyName = "Silverlight";
    sTextBox.DrawHighlight();
    Playback.Wait(2000);

    sTextBox.SetProperty(SilverlightEdit.PropertyNames.Text, "Thank god");

    SilverlightButton sButton = new SilverlightButton(sCustom);
    sButton.TechnologyName = "Silverlight";
    sButton.SearchProperties.Add(SilverlightButton.PropertyNames.DisplayText, "Button");

    sButton.DrawHighlight();

    Playback.Wait(2000);

    Mouse.Click(sButton);

    SilverlightComboBox sComboBox= new SilverlightComboBox(sCustom);
    sComboBox.TechnologyName = "Silverlight";

    sComboBox.DrawHighlight();

    Playback.Wait(2000);

    sComboBox.SetProperty(SilverlightComboBox.PropertyNames.SelectedItem,"Kishore");
}

Thanks,

You may hand write less code but its going to likely be less maintainable and more prone to breaking. You can use the partial class to effectively override the search clauses after the code has been generated.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top