Question

For a UI black box test I need to verify a certain UI interaction which results the opening of a certain directory via Process.Start("Some Folder");

The implementation of the code is already unit tested. While performing unit tests I mocked and verified the call to this but the UI is fully integrated and I need to verify that the bindings are correctly set (they rely on CommandParameter). Missing binding results in a Error 40 in console but calling a command with missing or wrong parameter is only detected during runtime.

Well Process Explorer shows me for explorer.exe the list of opened handles, how ever they are all marked as File and there plenty of files and directories with handles to them which are not directly shown as an open directory in the task bar of windows.

Was it helpful?

Solution

Well. The solution was so extremely trivial that it stuns me. I've tried various things like using WinApi hooks to hook into explorer.exe and ShellExecute WinApi calls and a managed wrapper. Then I thought about screenshot analysis :/

As I am using White for my WPF UI tests, which itself relies heavily on Microsoft's great UIAutomation framework and UIAutomation can do nearly everything I just needed to locate a window by means of automation:

 var desktop = AutomationElement.RootElement;
 foreach (AutomationElement element in desktop.FindAll(TreeScope.Children, Condition.TrueCondition))
 {
     if (element.Current.ClassName != "CabinetWClass")
     {
          continue;
     }
     Console.WriteLine("{0}, {1}",element.Current.Name, element.Current.ClassName);
 }

Do not forget to add UIAutomationClient and UIAutomationTypes assemblies and using System.Windows.Automation;

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top