2017-05-31 29 views
0

我无法使用White框架抓取文件资源管理器窗口。我在文件资源管理器上使用了Window的10 SDK Inspect工具来获取: Inspect Image在Windows文件浏览器中使用Teststack White

正如您可以注意到窗口名称为空。

为了抓住窗口,至少从docs开始,您需要使用名称为GetWindow。我用这个代码块:

Application application = Application.Launch("C:\\Window\\explorer.exe"); 
System.Threading.Thread.Sleep(10000); 
List<Window> windows = Desktop.Instance.Windows(); 
for (int i = 0; i < windows.Count; i++) 
    Console.WriteLine(i + ". " + windows[i]); 
Window fileExplorer = application.GetWindow(""); 

环路输出显示所有窗口:(2.最有可能是文件资源管理器)

0:C:\用户\管理员\文件\的Visual Studio 2017 \ foo.exe的

1:FOO(运行) - 微软的Visual Studio

2:

3:项目经理

而且GetWindow显示此:

无法找到标题窗口的过程6296,等待30秒

我已经得到Teststack白色与其他应用程序运行后当名称在检查中给出时,它似乎不是Teststack White的问题,而是使用File Explorer,因为它没有名称。但是,还有没有其他方法可以让TestStack抓取文件浏览器窗口。

TL; DR:如何让TestStack White框架获取窗口的文件资源管理器窗口以向其发送命令?

回答

0

TestStack白色太有限了。切换到微软的UI自动化。使用

var fileExplorer = 
AutomationElement.RootElement.FindFirst(TreeScope.Children, 
new PropertyCondition(AutomationElement.NameProperty, "File Explorer")); 

获取文件资源管理器。