我正在尝试创建一个Coded UI属性,用于检查打开的WMP文件。
public BrowserWindow VideoWindow
{
get
{
if (this._videoWindow == null || !this._videoWindow.Exists)
{
this._videoWindow = new BrowserWindow();
this._videoWindow.SearchProperties["Name"] = "Windows Media Player";
this._videoWindow.SearchProperties["ControlType"] = "Window";
}
return this._videoWindow;
}
}
显然,这不起作用。最初,该应用程序打开了一个视频网站的链接。所以这很有效,但由于它与BrowserWindow有点不同,我不知道该怎么做。我如何使用Coded UI“抓住”它?
答案 0 :(得分:1)
来自您一直在处理的视频网站的Windows媒体播放器的唯一真正区别是Windows媒体播放器将是WpfWindow而不是BrowserWindow -
public WpfWindow VideoWindow
{
get
{
if (this._videoWindow == null || !this._videoWindow.Exists)
{
this._videoWindow = new WpfWindow();
this._videoWindow.SearchProperties["Name"] = "Windows Media Player";
this._videoWindow.WindowTitles.Add("Windows Media Player");
}
return this._videoWindow;
}
}
之后,您只需要在媒体播放器窗口(WpfControls而不是HtmlControls)中获取控件,以确定哪个文件是打开的。