public GridFilter()
    Require(stack => stack.Peek().UIElement.ControlTypeName == "Cell");

protected override void Run(IUITestActionStack stack)
    UITestAction action = stack.Peek();
    action.UIElement.QueryId.Condition =
        new AndCondition(new PropertyCondition("Name", action.UIElement.Name));
    // The parent row must also be referred to by name.
    var parent = action.UIElement.QueryId.Ancestor;
    if (parent != null)
        parent.QueryId.Condition =
            new AndCondition(new PropertyCondition("Name", parent.Name));

The GridFilter is a simple filter to fix the way cells are searched for in playback. Normally, the value of a UI element is considered more unique than its name. This means that if a UI element is clicked on has a value that is not empty, the recorder will prioritize that identifying information. Normally this works well, but grids have odd behavior that makes the values during recording and during playback inconsistent. To fix this, the name is used instead, which is a proxy for their row-column index.

Last edited Aug 1, 2014 at 7:24 PM by wgoodin, version 6