简体   繁体   中英

Coded UI Test checking for an open Windows Media Player file

I am trying to create a Coded UI property that checks for an open WMP file.

   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;
        }
    }

Obviously, this will not work. Originally, the application opened a link to a video site. So this worked, but since it is quite a bit different than a BrowserWindow I am not sure how to do it. How can I use Coded UI to "grab" it?

The only real difference for windows media player from the video site you've been dealing with is that windows media player will be a WpfWindow instead of a 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;
    }
}

After that, you just have to get the controls inside of the media player window(WpfControls instead of HtmlControls) to determine which file is open.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM