c# - 检查打开的 Windows Media Player 文件的编码 UI 测试

标签 c# testing coded-ui-tests windows-media-player

我正在尝试创建一个编码的 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 来“抓取”它?

最佳答案

windows media player 与您一直在处理的视频网站的唯一真正区别是 windows media player 将是 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)来确定哪个文件已打开。

关于c# - 检查打开的 Windows Media Player 文件的编码 UI 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18666405/

相关文章:

c# - 网络 docker 容器上的 HttpClient 请求

c# - 可空枚举或附加元素

testing - 模拟nagios通知

c# - 使用codedui进行跨浏览器测试?

c# - 编码 Ui :Mouse click with coordinates

c# - 在不知道 sqlDbType 的情况下将 DBNull.Value 与 SqlParameter 一起使用?

c# - 带有详细信息表的 JQuery 网格

testing - 使用外部服务/api 的代码的 TDD BDD 最佳实践

javascript - Protractor 预期返回用括号而不是引号

.net - 无法加载文件或程序集 不支持操作。 (来自 HRESULT : 0x80131515) 的异常