6. Action Filter of Sample Excel Extension

This is the sixth & last post in this series on the extensibility of Coded UI Test. Before reading this, you should read the previous posts of this series to better understand this post.

The action filters are responsible to do filtering and aggregation of actions based on the rules specified to make recording more abstract and resilient. For example, let say the user doing the recording on Windows 7, did the following actions –

  • Click on Windows’ Start button
  • Typed “notepad” in search box
  • Click on Notepad list item from the result to launch notepad.exe.

The tool has built-in rule to aggregate out the above 3 actions into one action – Launch of notepad.exe. This makes recording more resilient because user can now play the same on Windows XP where the search box is not there. We call this “Intent Based Recording”.

The ExcelActionFilter class extends from UITestActionFilter to implement one such filtering rule specific to Excel extension. The rule is to remove the left click on a cell preceding a typing on the same cell. This is just to remove redundant mouse click. The UITestActionFilter has bunch of properties to implement but one method –

public override bool ProcessRule(IUITestActionStack actionStack)

This method is called for each action by the engine. The filter will have the logic here to process the stack of the actions (last one at the top) as appropriate. The filter simply does pop\push of actions as appropriate. It can even create new action and push it. In this sample, the filter simply checks for the left click on a cell preceding a typing on the same cell and if this is true, it removes the left click action.

This concludes the current series on Coded UI Test extensibility. Be on a lookout for more blogs around this topic in future!

Comments (0)