/// <summary> /// Deletes the index of the data grid view by. /// </summary> /// <param name="data">The data.</param> public static void DeleteDataGridViewByIndex(string[] data) { WinTable table = ( WinTable )Robot.FindWinControl(typeof(WinTable), data[0], _root); WinRow row = new WinRow(table); if (data[3] == string.Empty) { Mouse.Click(table, System.Windows.Forms.MouseButtons.Right); } else { row.SearchProperties.Add(WinRow.PropertyNames.RowIndex, data[3]); row.Find(); UITestControlCollection collection = row.GetChildren(); Mouse.Click(collection[0]); Mouse.Click(collection[0], System.Windows.Forms.MouseButtons.Right); } WinWindow window = new WinWindow(); WinMenu menu = new WinMenu(window); menu.SearchProperties[WinMenu.PropertyNames.Name] = data[1]; WinMenuItem item = new WinMenuItem(menu); item.SearchProperties[WinMenuItem.PropertyNames.Name] = data[2]; Mouse.Click(item); }
/// <summary> /// 尋找DataGridView 裡的NumericUpDown Cell控制項 /// </summary> /// <param name="dataGridViewName">DatGridView的AccessibleName</param> /// <param name="rowIndex">Row的Index,從0開始</param> /// <param name="columnIndex">Column的Index,從0開始</param> /// <param name="direct">欲按的NumericUpDown的增加或減少鍵(增加=NumericDirect.UP,減少=NumericDirect.DOWN)(</param> public static void ClickNumericUpDownButtonInDataGridView(string dataGridViewName, int rowIndex, int columnIndex, NumericDirect direct, int times) { const int HALF_BUTTON_WIDTH = 8; const int SPINBUTTON_HEIGHT_FINE_TUNE = 3; WinTable table = Robot.FindWinControl(typeof(WinTable), dataGridViewName, _root) as WinTable; WinRow row = table.Rows[rowIndex] as WinRow; WinCell cell = row.Cells[columnIndex] as WinCell; Rectangle boundingRectangle = cell.BoundingRectangle; int halfHeightOfCell = cell.BoundingRectangle.Height / 2; int upperPartYOffset = halfHeightOfCell - SPINBUTTON_HEIGHT_FINE_TUNE; int lowerPartYOffset = halfHeightOfCell + SPINBUTTON_HEIGHT_FINE_TUNE; switch (direct) { case NumericDirect.UP: Mouse.Click(new Point(boundingRectangle.X + boundingRectangle.Width - HALF_BUTTON_WIDTH, boundingRectangle.Y + upperPartYOffset)); break; case NumericDirect.DOWN: Mouse.Click(new Point(boundingRectangle.X + boundingRectangle.Width - HALF_BUTTON_WIDTH, boundingRectangle.Y + lowerPartYOffset)); break; } for (int i = 0; i < times + 1; i++) { Mouse.Click(); } Keyboard.SendKeys("{Enter}"); }
public static void ClickButtonInDataGridView(string dataGridViewName, int rowIndex, int columnIndex) { WinTable table = Robot.FindWinControl(typeof(WinTable), dataGridViewName, _root) as WinTable; WinRow row = table.Rows[rowIndex] as WinRow; WinCell cell = row.Cells[columnIndex] as WinCell; Mouse.Click(cell); }
/// <summary> /// 測試一DataGridView裡的NumericUpDown Cell的值 /// </summary> /// <param name="dataGridViewName">DataGridView 的 AccesibleName</param> /// <param name="rowIndex">NumericUpDown cell所在的row index </param> /// <param name="columnIndex">NumericUpDown cell 所在的 column index</param> /// <param name="value">欲測值</param> public static void AssertDataGridViewNumericUpDownCellValue(string dataGridViewName, int rowIndex, int columnIndex, int value) { WinTable table = Robot.FindWinControl(typeof(WinTable), dataGridViewName, _root) as WinTable; WinRow row = table.Rows[rowIndex] as WinRow; WinCell cell = row.Cells[columnIndex] as WinCell; Assert.AreEqual(cell.Value, value.ToString()); }
private static WinTable GetWinTable(string uiTitle, string uiType) { var htmlcontrolWin = new WinTable(Window.Locate(uiTitle, uiType)); var htmlControlWin = htmlcontrolWin; htmlControlWin.TechnologyName = TechnologyNameWin; return(htmlControlWin); }
/// <summary> /// Assert the specific data grid view's cell /// </summary> /// <param name="name">The data grid view's name</param> /// <param name="rowIndex">row index</param> /// <param name="columnIndex">column index</param> /// <param name="expectedValue">expected value you want to assert</param> /// <exception cref="Exception">If the control is not found</exception> public static void AssertGridViewCell(string name, int rowIndex, int columnIndex, string expectedValue) { WinTable gridView = (WinTable)Robot.FindWinControl(typeof(WinTable), name, _root); WinRow row = (WinRow)gridView.Rows[rowIndex]; WinCell cell = (WinCell)row.Cells[columnIndex]; Assert.AreEqual(expectedValue, cell.GetProperty("Value").ToString()); }
/// <summary> /// AssertMethod1 - Verwenden Sie "AssertMethod1ExpectedValues", um Parameter an diese Methode zu übergeben. /// </summary> public void AssertMethod1() { #region Variable Declarations WinTable uIDataGridViewTable = this.UITransportAppWindow.UIDgV_VerbindungenWindow.UIDataGridViewTable; #endregion // Sicherstellen, dass die Eigenschaft 'ControlType' von "DataGridView" Tabelle ist gleich 'Table' Assert.AreEqual(this.AssertMethod1ExpectedValues.UIDataGridViewTableControlType, uIDataGridViewTable.ControlType.ToString()); }
public static void DeleteDataGridViewRowByIndex(string name, string index) { WinTable table = (WinTable)Robot.FindWinControl(typeof(WinTable), name, _root); WinRow row = new WinRow(table); row.SearchProperties.Add(WinRow.PropertyNames.RowIndex, index); UITestControlCollection collection = row.GetChildren(); Mouse.Click(collection[0]); }
public static WinTable GetTable(string name, string itemWindowID, WinWindow parent) { WinWindow ItemWindow = new WinWindow(parent); ItemWindow.SearchProperties[WinWindow.PropertyNames.ControlId] = itemWindowID; ItemWindow.WaitForControlReady(); WinTable mUITable = new WinTable(ItemWindow); mUITable.SearchProperties[WinTable.PropertyNames.Name] = name; mUITable.WaitForControlReady(); return mUITable; }
public static void ClickDeleteButtonInDataGridView(string dataGridViewName, int rowIndex, int columnIndex) { WinWindow sec = Robot.FindWinControl(typeof(WinWindow), "CustomerSideForm", null) as WinWindow; // WinTable table = Robot.FindWinControl(typeof(WinTable), dataGridViewName, sec) as WinTable; WinRow row = table.Rows[rowIndex] as WinRow; WinCell cell = row.Cells[columnIndex] as WinCell; Mouse.Click(cell); }
/// <summary> /// Clicks the data grid view cell. /// </summary> /// <param name="name">The name.</param> /// <param name="rowIndex">Index of the row.</param> /// <param name="cellIndex">Index of the cell.</param> public static void ClickDataGridViewCell(string name, string rowIndex, string cellIndex) { WinTable table = ( WinTable )Robot.FindWinControl(typeof(WinTable), name, _root); WinRow row = new WinRow(table); row.SearchProperties.Add(WinRow.PropertyNames.RowIndex, rowIndex); UITestControlCollection collection = row.GetChildren(); Mouse.Click(collection[int.Parse(cellIndex)]); }
/// <summary> /// Assert DataGridView所選Cell顯示的顏色(請勿讓Cell反白,否則可能會錯誤) /// </summary> /// <param name="dataGridViewName">DataGridView的AccessibleName</param> /// <param name="rowIndex">Row的Index,以0開始</param> /// <param name="columnIndex">Column的Index,以0開始</param> /// <param name="color">待測顏色</param> public static void AssertCellColor(string dataGridViewName, int rowIndex, int columnIndex, Color color) { WinTable table = (WinTable)Robot.FindWinControl(typeof(WinTable), dataGridViewName, _root); WinRow row = (WinRow)table.Rows[rowIndex]; WinCell cell = (WinCell)row.Cells[columnIndex]; Image image = cell.CaptureImage(); Bitmap bitmap = new Bitmap(image); Color pixelColor = bitmap.GetPixel(image.Width / 2, image.Height / 2); Assert.AreEqual(pixelColor.ToArgb(), color.ToArgb()); }
public static void SetDataGridViewValue(string name, string row, string col, string text) { WinTable dataGridView = (WinTable)Robot.FindWinControl(typeof(WinTable), name, _root); WinRow dataGridRow = new WinRow(dataGridView); dataGridRow.SearchProperties.Add(WinRow.PropertyNames.RowIndex, row); UITestControlCollection collection = dataGridRow.GetChildren(); Mouse.Click(collection[int.Parse(col)]); Keyboard.SendKeys(collection[int.Parse(col)], text + "\r\n"); }
public static void AssertDataGridViewValue(string name, string row, string col, string key) { WinTable table = (WinTable)Robot.FindWinControl(typeof(WinTable), name, _root); WinRow _Winrow = new WinRow(table); _Winrow.SearchProperties.Add(WinRow.PropertyNames.RowIndex, row); _Winrow.Find(); UITestControlCollection collection = _Winrow.GetChildren(); WinCell cell = collection[int.Parse(col)] as WinCell; Assert.AreEqual(key, cell.Value); }
public static void SetDataGridViewQuantity(string name, string index, string qty) { WinTable table = (WinTable)Robot.FindWinControl(typeof(WinTable), name, _root); WinRow _Winrow = new WinRow(table); _Winrow.SearchProperties.Add(WinRow.PropertyNames.RowIndex, index); _Winrow.Find(); UITestControlCollection collection = _Winrow.GetChildren(); WinCell cell = collection[4] as WinCell; cell.Value = qty; }
/// <summary> /// Sets the data grid view cell. /// </summary> /// <param name="name">The name.</param> /// <param name="rowIndex">Index of the row.</param> /// <param name="cellIndex">Index of the cell.</param> /// <param name="value">The value.</param> public static void SetDataGridViewCell(string name, string rowIndex, int cellIndex, string value) { WinTable table = ( WinTable )Robot.FindWinControl(typeof(WinTable), name, _root); WinRow _Winrow = new WinRow(table); _Winrow.SearchProperties.Add(WinRow.PropertyNames.RowIndex, rowIndex); _Winrow.Find(); UITestControlCollection collection = _Winrow.GetChildren(); WinCell cell = collection[cellIndex] as WinCell; cell.Value = value; Keyboard.SendKeys("{Enter}"); }
/// <summary> /// Asserts the index of the data grid view by. /// </summary> /// <param name="name">The name.</param> /// <param name="index">The index.</param> /// <param name="data">The data.</param> public static void AssertDataGridViewByIndex(string name, string index, string[] data) { WinTable table = ( WinTable )Robot.FindWinControl(typeof(WinTable), name, _root); WinRow _Winrow = new WinRow(table); _Winrow.SearchProperties.Add(WinRow.PropertyNames.RowIndex, index); _Winrow.Find(); UITestControlCollection collection = _Winrow.GetChildren(); for (int i = 0; i < collection.Count; i++) { WinCell cell = collection[i] as WinCell; Assert.AreEqual(data[i], cell.Value); } }
public Table(WinTable element) { this.element = element; }
public WinTable GetCUITDataTable(WinWindow w, string searchBy, string searchValue, int index) { Console.WriteLine("Inside function GetCUITDataRow"); WinTable GetCUITDataTable = new WinTable(w); Playback.Initialize(); try { switch (searchBy.Trim().ToLower()) { case "text": { if (index == -1) { GetCUITDataTable.SearchProperties[WinTable.PropertyNames.Name] = searchValue; } else { GetCUITDataTable.SearchProperties.Add(WinTable.PropertyNames.Name, searchValue); UITestControlCollection editCollection = GetCUITDataTable.FindMatchingControls(); GetCUITDataTable = (WinTable)editCollection[index]; } break; } case "automationid": { if (index == -1) { GetCUITDataTable.SearchProperties.Add(WinTable.PropertyNames.ControlName, searchValue); UITestControlCollection editCollection = GetCUITDataTable.FindMatchingControls(); GetCUITDataTable = (WinTable)editCollection[0]; } else { GetCUITDataTable.SearchProperties.Add(WinTable.PropertyNames.ControlName, searchValue); UITestControlCollection editCollection = GetCUITDataTable.FindMatchingControls(); GetCUITDataTable = (WinTable)editCollection[index]; } break; } default: throw new Exception(_error); } Playback.Cleanup(); Console.WriteLine("Found Data Row and exiting function GetCUITDataRow"); return GetCUITDataTable; } catch (Exception e) { var st = new StackTrace(e, true); var testFrame = st.GetFrame(0); for (int i = 0; i < st.FrameCount; i++) { testFrame = st.GetFrame(i); if (testFrame.GetFileName() != null) { if (testFrame.GetFileName().ToString().Contains("CUITFramework.cs") == true) { break; } } } // Get the top stack frame var frame = testFrame; // Get the line number from the stack frame var line = frame.GetFileLineNumber(); logTofile(_eLogPtah, "Error in GetCUITEdit and in line: " + line); throw new Exception(_error + "CUITRButton:" + System.Environment.NewLine + e.Message); } }
/// <summary> /// Click the specific gridview cell /// </summary> /// <param name="name">The gridview's name</param> /// <param name="index">The index of list</param> /// <exception cref="Exception">If the control is not found</exception> public static void ClickGridViewCell(string name, int index) { WinTable gridView = (WinTable)Robot.FindWinControl(typeof(WinTable), name, _root); Mouse.Click(gridView.RowHeaders[index]); }
/// <summary> /// Asserts the data items in data grid view. /// </summary> /// <param name="name">The name.</param> /// <param name="items">The items.</param> public static void AssertDataItemsInDataGridView(string name, int items) { WinTable table = ( WinTable )Robot.FindWinControl(typeof(WinTable), name, _root); Assert.AreEqual(table.Rows.Count, items); }
/// <summary> /// Assert the specific data grid view row count /// </summary> /// <param name="name">The data grid view's name</param> /// <param name="expectedValue">expected value you want to assert</param> /// <exception cref="Exception">If the control is not found</exception> public static void AssertGridViewRowCount(string name, int expectedValue) { WinTable gridView = (WinTable)Robot.FindWinControl(typeof(WinTable), name, _root); Assert.AreEqual(expectedValue, gridView.Rows.Count); }