编码的 UI 测试检查打开的Windows 媒体播放器文件

本文关键字:Windows 媒体播放器 文件 检查 UI 测试 编码 | 更新日期: 2023-09-27 18:30:25

我正在尝试创建一个编码的 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;
        }
    }

显然,这是行不通的。最初,该应用程序打开了一个视频网站的链接。所以这有效,但由于它与浏览器窗口有很大不同,我不确定该怎么做。如何使用编码的 UI 来"抓取"它?

编码的 UI 测试检查打开的Windows 媒体播放器文件

Windows 媒体播放器

与您一直在处理的视频网站的唯一真正区别是Windows 媒体播放器将是 WpfWindow 而不是浏览器窗口 -

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)即可确定打开哪个文件。