I am trying to use CodedUI, but it's not working with RadTextBox.
I created a test app with 5 textboxes, and recorded a test that fills out all those textbox.
When I try to run the test, it fails, claiming the element is no longer available.
Since I cannon attach my entire solution, I'll just paste come code below.
The form itself is trivial, it just contains 5 RadTextBox elements
The interesting pars in the testing code, so I am pasting it below.
CodedUiTest1.cs
using Microsoft.VisualStudio.TestTools.UITesting;using Microsoft.VisualStudio.TestTools.UnitTesting;namespace CodedUITestProject1{ [CodedUITest] public class CodedUITest1 { public CodedUITest1() { } [TestMethod] public void CodedUITestMethod1() { var aut = ApplicationUnderTest.Launch(@"C:\Users\pg2\Documents\visual studio 2015\Projects\Solution2\TelerikWinFormsApp1\bin\Debug\TelerikWinFormsApp1.exe"); this.UIMap.RecordedMethod1(); } public TestContext TestContext { get { return testContextInstance; } set { testContextInstance = value; } } private TestContext testContextInstance; public UIMap UIMap { get { if ((this.map == null)) { this.map = new UIMap(); } return this.map; } } private UIMap map; }}
UIMap.Designer.cs
namespace CodedUITestProject1{ using Microsoft.VisualStudio.TestTools.UITest.Extension; using Microsoft.VisualStudio.TestTools.UITesting; using Microsoft.VisualStudio.TestTools.UITesting.WinControls; using System.CodeDom.Compiler; using System.Drawing; using Mouse = Microsoft.VisualStudio.TestTools.UITesting.Mouse; [GeneratedCode("Coded UITest Builder", "14.0.23107.0")] public partial class UIMap { /// <summary> /// RecordedMethod1 - Use 'RecordedMethod1Params' to pass parameters into this method. /// </summary> public void RecordedMethod1() { #region Variable Declarations WinEdit uIItemEdit = this.UIRadForm1Window.UIRadForm1Client.UIRadTextBox1Edit.UIItemEdit; WinEdit uIItemEdit1 = this.UIRadForm1Window.UIItemEdit; WinEdit uIItemEdit2 = this.UIRadForm1Window.UIRadForm1Client.UIRadTextBox2Edit.UIItemEdit; WinEdit uIItemEdit11 = this.UIRadForm1Window.UIItemEdit1; WinEdit uIItemEdit3 = this.UIRadForm1Window.UIRadForm1Client.UIRadTextBox3Edit.UIItemEdit; WinEdit uIItemEdit21 = this.UIRadForm1Window.UIItemEdit2; WinWindow uIItemWindow = this.UIRadForm1Window.UIRadForm1Client.UIRadTextBox4Window.UIItemWindow; WinEdit uIItemEdit4 = this.UIRadForm1Window.UIRadForm1Client.UIRadTextBox4Edit.UIItemEdit; WinEdit uIItemEdit31 = this.UIRadForm1Window.UIItemEdit3; WinEdit uIItemEdit5 = this.UIRadForm1Window.UIRadForm1Client.UIRadTextBox5Edit.UIItemEdit; WinEdit uIItemEdit41 = this.UIRadForm1Window.UIItemEdit4; WinClient uIRadForm1Client = this.UIRadForm1Window.UIRadForm1Client; #endregion // Click text box Mouse.Click(uIItemEdit, new Point(62, 1)); // Type 'aaa' in text box uIItemEdit1.Text = this.RecordedMethod1Params.UIItemEditText; // Click text box Mouse.Click(uIItemEdit2, new Point(18, 14)); // Type 'bbb' in text box uIItemEdit11.Text = this.RecordedMethod1Params.UIItemEdit1Text; // Click text box Mouse.Click(uIItemEdit3, new Point(17, 10)); // Type 'ccc' in text box uIItemEdit21.Text = this.RecordedMethod1Params.UIItemEdit2Text; // Click window Mouse.Click(uIItemWindow, new Point(17, -1)); // Click text box Mouse.Click(uIItemEdit4, new Point(20, 1)); // Type 'ddd' in text box uIItemEdit31.Text = this.RecordedMethod1Params.UIItemEdit3Text; // Click text box Mouse.Click(uIItemEdit5, new Point(38, 9)); // Type 'eee' in text box uIItemEdit41.Text = this.RecordedMethod1Params.UIItemEdit4Text; // Click 'RadForm1' client Mouse.Click(uIRadForm1Client, new Point(88, 149)); } #region Properties public virtual RecordedMethod1Params RecordedMethod1Params { get { if ((this.mRecordedMethod1Params == null)) { this.mRecordedMethod1Params = new RecordedMethod1Params(); } return this.mRecordedMethod1Params; } } public UIRadForm1Window UIRadForm1Window { get { if ((this.mUIRadForm1Window == null)) { this.mUIRadForm1Window = new UIRadForm1Window(); } return this.mUIRadForm1Window; } } #endregion #region Fields private RecordedMethod1Params mRecordedMethod1Params; private UIRadForm1Window mUIRadForm1Window; #endregion } /// <summary> /// Parameters to be passed into 'RecordedMethod1' /// </summary> [GeneratedCode("Coded UITest Builder", "14.0.23107.0")] public class RecordedMethod1Params { #region Fields /// <summary> /// Type 'aaa' in text box /// </summary> public string UIItemEditText = "aaa"; /// <summary> /// Type 'bbb' in text box /// </summary> public string UIItemEdit1Text = "bbb"; /// <summary> /// Type 'ccc' in text box /// </summary> public string UIItemEdit2Text = "ccc"; /// <summary> /// Type 'ddd' in text box /// </summary> public string UIItemEdit3Text = "ddd"; /// <summary> /// Type 'eee' in text box /// </summary> public string UIItemEdit4Text = "eee"; #endregion } [GeneratedCode("Coded UITest Builder", "14.0.23107.0")] public class UIRadForm1Window : WinWindow { public UIRadForm1Window() { #region Search Criteria this.SearchProperties[WinWindow.PropertyNames.Name] = "RadForm1"; this.SearchProperties.Add(new PropertyExpression(WinWindow.PropertyNames.ClassName, "WindowsForms10.Window", PropertyExpressionOperator.Contains)); this.WindowTitles.Add("RadForm1"); #endregion } #region Properties public UIRadForm1Client UIRadForm1Client { get { if ((this.mUIRadForm1Client == null)) { this.mUIRadForm1Client = new UIRadForm1Client(this); } return this.mUIRadForm1Client; } } public WinEdit UIItemEdit { get { if ((this.mUIItemEdit == null)) { this.mUIItemEdit = new WinEdit(this); #region Search Criteria this.mUIItemEdit.WindowTitles.Add("RadForm1"); #endregion } return this.mUIItemEdit; } } public WinEdit UIItemEdit1 { get { if ((this.mUIItemEdit1 == null)) { this.mUIItemEdit1 = new WinEdit(this); #region Search Criteria this.mUIItemEdit1.WindowTitles.Add("RadForm1"); #endregion } return this.mUIItemEdit1; } } public WinEdit UIItemEdit2 { get { if ((this.mUIItemEdit2 == null)) { this.mUIItemEdit2 = new WinEdit(this); #region Search Criteria this.mUIItemEdit2.WindowTitles.Add("RadForm1"); #endregion } return this.mUIItemEdit2; } } public WinEdit UIItemEdit3 { get { if ((this.mUIItemEdit3 == null)) { this.mUIItemEdit3 = new WinEdit(this); #region Search Criteria this.mUIItemEdit3.WindowTitles.Add("RadForm1"); #endregion } return this.mUIItemEdit3; } } public WinEdit UIItemEdit4 { get { if ((this.mUIItemEdit4 == null)) { this.mUIItemEdit4 = new WinEdit(this); #region Search Criteria this.mUIItemEdit4.WindowTitles.Add("RadForm1"); #endregion } return this.mUIItemEdit4; } } #endregion #region Fields private UIRadForm1Client mUIRadForm1Client; private WinEdit mUIItemEdit; private WinEdit mUIItemEdit1; private WinEdit mUIItemEdit2; private WinEdit mUIItemEdit3; private WinEdit mUIItemEdit4; #endregion } [GeneratedCode("Coded UITest Builder", "14.0.23107.0")] public class UIRadForm1Client : WinClient { public UIRadForm1Client(UITestControl searchLimitContainer) : base(searchLimitContainer) { #region Search Criteria this.SearchProperties[WinControl.PropertyNames.Name] = "RadForm1"; this.WindowTitles.Add("RadForm1"); #endregion } #region Properties public UIRadTextBox1Edit UIRadTextBox1Edit { get { if ((this.mUIRadTextBox1Edit == null)) { this.mUIRadTextBox1Edit = new UIRadTextBox1Edit(this); } return this.mUIRadTextBox1Edit; } } public UIRadTextBox2Edit UIRadTextBox2Edit { get { if ((this.mUIRadTextBox2Edit == null)) { this.mUIRadTextBox2Edit = new UIRadTextBox2Edit(this); } return this.mUIRadTextBox2Edit; } } public UIRadTextBox3Edit UIRadTextBox3Edit { get { if ((this.mUIRadTextBox3Edit == null)) { this.mUIRadTextBox3Edit = new UIRadTextBox3Edit(this); } return this.mUIRadTextBox3Edit; } } public UIRadTextBox4Window UIRadTextBox4Window { get { if ((this.mUIRadTextBox4Window == null)) { this.mUIRadTextBox4Window = new UIRadTextBox4Window(this); } return this.mUIRadTextBox4Window; } } public UIRadTextBox4Edit UIRadTextBox4Edit { get { if ((this.mUIRadTextBox4Edit == null)) { this.mUIRadTextBox4Edit = new UIRadTextBox4Edit(this); } return this.mUIRadTextBox4Edit; } } public UIRadTextBox5Edit UIRadTextBox5Edit { get { if ((this.mUIRadTextBox5Edit == null)) { this.mUIRadTextBox5Edit = new UIRadTextBox5Edit(this); } return this.mUIRadTextBox5Edit; } } #endregion #region Fields private UIRadTextBox1Edit mUIRadTextBox1Edit; private UIRadTextBox2Edit mUIRadTextBox2Edit; private UIRadTextBox3Edit mUIRadTextBox3Edit; private UIRadTextBox4Window mUIRadTextBox4Window; private UIRadTextBox4Edit mUIRadTextBox4Edit; private UIRadTextBox5Edit mUIRadTextBox5Edit; #endregion } [GeneratedCode("Coded UITest Builder", "14.0.23107.0")] public class UIRadTextBox1Edit : WinEdit { public UIRadTextBox1Edit(UITestControl searchLimitContainer) : base(searchLimitContainer) { #region Search Criteria this.SearchConfigurations.Add(SearchConfiguration.VisibleOnly); this.WindowTitles.Add("RadForm1"); #endregion } #region Properties public WinEdit UIItemEdit { get { if ((this.mUIItemEdit == null)) { this.mUIItemEdit = new WinEdit(this); #region Search Criteria this.mUIItemEdit.WindowTitles.Add("RadForm1"); #endregion } return this.mUIItemEdit; } } #endregion #region Fields private WinEdit mUIItemEdit; #endregion } [GeneratedCode("Coded UITest Builder", "14.0.23107.0")] public class UIRadTextBox2Edit : WinEdit { public UIRadTextBox2Edit(UITestControl searchLimitContainer) : base(searchLimitContainer) { #region Search Criteria this.SearchConfigurations.Add(SearchConfiguration.VisibleOnly); this.WindowTitles.Add("RadForm1"); #endregion } #region Properties public WinEdit UIItemEdit { get { if ((this.mUIItemEdit == null)) { this.mUIItemEdit = new WinEdit(this); #region Search Criteria this.mUIItemEdit.WindowTitles.Add("RadForm1"); #endregion } return this.mUIItemEdit; } } #endregion #region Fields private WinEdit mUIItemEdit; #endregion } [GeneratedCode("Coded UITest Builder", "14.0.23107.0")] public class UIRadTextBox3Edit : WinEdit { public UIRadTextBox3Edit(UITestControl searchLimitContainer) : base(searchLimitContainer) { #region Search Criteria this.SearchConfigurations.Add(SearchConfiguration.VisibleOnly); this.WindowTitles.Add("RadForm1"); #endregion } #region Properties public WinEdit UIItemEdit { get { if ((this.mUIItemEdit == null)) { this.mUIItemEdit = new WinEdit(this); #region Search Criteria this.mUIItemEdit.WindowTitles.Add("RadForm1"); #endregion } return this.mUIItemEdit; } } #endregion #region Fields private WinEdit mUIItemEdit; #endregion } [GeneratedCode("Coded UITest Builder", "14.0.23107.0")] public class UIRadTextBox4Window : WinWindow { public UIRadTextBox4Window(UITestControl searchLimitContainer) : base(searchLimitContainer) { #region Search Criteria this.SearchProperties[WinWindow.PropertyNames.ControlName] = "radTextBox4"; this.SearchConfigurations.Add(SearchConfiguration.VisibleOnly); this.WindowTitles.Add("RadForm1"); #endregion } #region Properties public WinWindow UIItemWindow { get { if ((this.mUIItemWindow == null)) { this.mUIItemWindow = new WinWindow(this); #region Search Criteria this.mUIItemWindow.SearchProperties.Add(new PropertyExpression(WinWindow.PropertyNames.ClassName, "WindowsForms10.EDIT", PropertyExpressionOperator.Contains)); this.mUIItemWindow.SearchConfigurations.Add(SearchConfiguration.VisibleOnly); this.mUIItemWindow.WindowTitles.Add("RadForm1"); #endregion } return this.mUIItemWindow; } } #endregion #region Fields private WinWindow mUIItemWindow; #endregion } [GeneratedCode("Coded UITest Builder", "14.0.23107.0")] public class UIRadTextBox4Edit : WinEdit { public UIRadTextBox4Edit(UITestControl searchLimitContainer) : base(searchLimitContainer) { #region Search Criteria this.SearchConfigurations.Add(SearchConfiguration.VisibleOnly); this.WindowTitles.Add("RadForm1"); #endregion } #region Properties public WinEdit UIItemEdit { get { if ((this.mUIItemEdit == null)) { this.mUIItemEdit = new WinEdit(this); #region Search Criteria this.mUIItemEdit.WindowTitles.Add("RadForm1"); #endregion } return this.mUIItemEdit; } } #endregion #region Fields private WinEdit mUIItemEdit; #endregion } [GeneratedCode("Coded UITest Builder", "14.0.23107.0")] public class UIRadTextBox5Edit : WinEdit { public UIRadTextBox5Edit(UITestControl searchLimitContainer) : base(searchLimitContainer) { #region Search Criteria this.SearchConfigurations.Add(SearchConfiguration.VisibleOnly); this.WindowTitles.Add("RadForm1"); #endregion } #region Properties public WinEdit UIItemEdit { get { if ((this.mUIItemEdit == null)) { this.mUIItemEdit = new WinEdit(this); #region Search Criteria this.mUIItemEdit.WindowTitles.Add("RadForm1"); #endregion } return this.mUIItemEdit; } } #endregion #region Fields private WinEdit mUIItemEdit; #endregion }}