51Testing软件测试论坛
标题:
使用Coded UI Test测试DataGridView遇到的问题
[打印本页]
作者:
老白的释然
时间:
2018-6-20 17:27
标题:
使用Coded UI Test测试DataGridView遇到的问题
使用以下方法对DataGridView的单元格进行随机赋值,实际运行中发现在Visual Studio 2010中无法执
行对TextBox单元格(WinEdit)的赋值,报错
PlaybackFailureException: 不能对控件执行“值为“12”的 Value 的 SetProperty”
后改用Visual Studio 2015可正常执行。
<p>
</p><p>
</p><p>
</p><p>[csharp] view plain copy</p><p>public void RecordedTest1() </p><p>{ </p><p> #region Variable Declarations </p><p> WinComboBox uIEditControlComboBox = this.UIMyWinFormWindow.UIMyWinForm2Window.UIItemWindow.UIEditPanelClient.UIEditControlComboBox; </p><p> WinEdit uIEditControlEdit = this.UIMyWinFormWindow.UIBMyWinForm2Window.UIItemWindow.UIEditPanelClient.UIEditControlEdit; </p><p> </p><p> WinTable uITable = this.UIMyWinFormWindow.UIMyWinForm2Window.UIGrvFenceWindow.UIDataGridViewTable; </p><p> WinRow uIRow; </p><p> WinCell uICell; </p><p> </p><p> #endregion </p><p> </p><p> Random rnd = new Random(13579); </p><p> for (int i = 0; i < uITable.Rows.Count; i++) </p><p> { </p><p> uIRow = uITable.Rows[i] as WinRow; </p><p> </p><p> //DataGridViewComboBox </p><p> uICell = uIRow.Cells[0] as WinCell; </p><p> Mouse.Click(uICell); </p><p> uIEditControlComboBox.SelectedIndex = rnd.Next(3); </p><p> </p><p> //DataGridViewTextBox </p><p> uICell = uIRow.Cells[1] as WinCell; </p><p> Mouse.Click(uICell); </p><p> uIEditControlEdit.Text = rnd.Next(100).ToString(); </p><p> } </p><p>} </p><div></div>
复制代码
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2