// Checks if two actions are on same cell or not. private static bool AreActionsOnSameExcelCell(SendKeysAction lastAction, MouseAction secondLastAction) { return(lastAction != null && secondLastAction != null && lastAction.UIElement is GridCellElement && secondLastAction.UIElement is GridCellElement && object.Equals(lastAction.UIElement, secondLastAction.UIElement)); }
// Checks if two actions are on same selection or not. private static bool AreActionsOnSameWordSelection(SendKeysAction lastAction, MouseAction secondLastAction) { return(lastAction != null && secondLastAction != null && lastAction.UIElement is WordSelectionRange && secondLastAction.UIElement is WordSelectionRange && object.Equals(lastAction.UIElement, secondLastAction.UIElement)); }
/// <summary> /// Processes the rule for this filter. /// The action stack can be modified by the filter if it matches it's filtering criteria. /// </summary> /// <param name="actionStack">The action stack.</param> /// <returns>True if no more filtering should be done in this cycle. False if the /// filtering should continue with action filters that follow.</returns> public override bool ProcessRule(IUITestActionStack actionStack) { // Remove the mouse click preceeding on send keys on the same Excel cell. SendKeysAction lastAction = actionStack.Peek() as SendKeysAction; MouseAction secondLastAction = actionStack.Peek(1) as MouseAction; if (IsLeftClick(secondLastAction) && AreActionsOnSameWordSelection(lastAction, secondLastAction)) { // This is left click on a cell preceding a typing on the same cell. // Remove the left click action. // (0 means top-most action and 1 means 2nd action & so on.) actionStack.Pop(1); } return(false); }
// Checks if two actions are on same cell or not. private static bool AreActionsOnSameExcelCell(SendKeysAction lastAction, MouseAction secondLastAction) { return lastAction != null && secondLastAction != null && lastAction.UIElement is ExcelCellElement && secondLastAction.UIElement is ExcelCellElement && object.Equals(lastAction.UIElement, secondLastAction.UIElement); }