5

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?

1
  • 1
    One of the scenarious could be that the Test recorder cannot locate controls. Or if the window titles of the container controls are dynamic Commented Jan 31, 2011 at 13:47

3 Answers 3

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I've been using CUITe since v1.0.1 and it's been great! :)
3

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,

2 Comments

Are you saying that you don't create UIMaps? Seems like a lot of this code should go into the UIMap files rather than the test method themselves to separate test Specification from test Implementation. Also it seems like you need to be very familiar with the Coded UI APIs to be able to hand write code like this
@EdmundYeung99 but I think it is really a good example of hand-only code.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.