1

我正在为 WebApp 手动编码 CodedUI 测试。Web 应用程序大约有 50% 的 Silverlight。我有一个 HtmlCustom 控件,可以在网页中搜索我的父对象。然后使用它为主页模板创建 SilverlightControl。页面模板也有一个与之关联的 ID。我在 web 应用程序的其他区域有此代码,它工作正常,但由于某种原因它不在这里。

    /// <summary>
    /// Parent of UIControlViewPlaylistsXAP
    /// </summary>
    private HtmlCustom mUICustomViewPlaylistsXAP;
    private HtmlCustom UICustomViewPlaylistsXAP
    {
        get
        {
            if (this.mUICustomViewPlaylistsXAP == null)
            {
                this.mUICustomViewPlaylistsXAP = new HtmlCustom(this);
                this.mUICustomViewPlaylistsXAP.SearchProperties.Add(HtmlCustom.PropertyNames.Id, "viewPlaylistsObject");
                this.mUICustomViewPlaylistsXAP.SearchProperties.Add(HtmlCustom.PropertyNames.TagName, "OBJECT");
                this.mUICustomViewPlaylistsXAP.SearchProperties.Add(HtmlCustom.PropertyNames.ControlDefinition, "data=\"data:application/x-oleobject;base64", PropertyExpressionOperator.Contains);
            }
            return this.mUICustomViewPlaylistsXAP;
        }
    }

    /// <summary>
    /// Parent of all direct Page: View Playlists controls
    /// </summary>
    private SilverlightControl mUIControlViewPlaylistsXAP;
    public SilverlightControl UIControlViewPlaylistsXAP
    {
        get
        {
            if (this.mUIControlViewPlaylistsXAP == null)
            {
                this.mUIControlViewPlaylistsXAP = new SilverlightControl(this.UICustomViewPlaylistsXAP);
                this.mUIControlViewPlaylistsXAP.SearchProperties.Add(SilverlightControl.PropertyNames.AutomationId, "VisiconnPageTemplate");
                ////this.mUIControlViewPlaylistsXAP.SearchProperties.Add(SilverlightControl.PropertyNames.MaxDepth, "-1");
                this.mUICustomViewPlaylistsXAP.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);
                //// this.mUIControlViewPlaylistsXAP.SearchProperties.Add(SilverlightControl.PropertyNames.ControlType, "VisiconnPageTemplate");

             }
            return this.mUIControlViewPlaylistsXAP;
        }
    }

所以 mUIControlViewPlaylists.XAP 会返回 UITestControlNotFoundException,它有与之关联的 AutomationId。如果有任何关于这样做的更好方法或一般问题的想法,他们肯定会受到赞赏。

4

0 回答 0