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,