0

我正在尝试自动化 sharepoint 2010 人员选择器,但即使突出显示窗口内的任何控件也非常困难。我使用手动编码来查找窗口,但窗口内的控件没有突出显示。

 WinWindow pp = new WinWindow(browserWindow);
        pp.TechnologyName = "MSAA";
        pp.SearchProperties[WinWindow.PropertyNames.ClassName] = "Internet Explorer_TridentDlgFrame";
        pp.SearchProperties[WinWindow.PropertyNames.ControlType] = "Window";
        pp.SearchProperties[WinWindow.PropertyNames.Name] = "Select People -- Webpage Dialog";
        pp.Find();
        pp.DrawHighlight();

Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDocument doc = new Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDocument(pp);
        doc.TechnologyName = "Web";
        doc.SearchProperties[Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDocument.PropertyNames.TagName] = "BODY";
        doc.SearchProperties[Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDocument.PropertyNames.FrameDocument] = "False";
        doc.SearchProperties[Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDocument.PropertyNames.RedirectingPage] = "False";
        doc.SearchProperties[Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDocument.PropertyNames.ControlType] = "Document";
        doc.SearchProperties[Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDocument.PropertyNames.Title] = "Select People";
        doc.SearchProperties[Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDocument.PropertyNames.PageUrl] = PAGE_URL_Here;
        doc.SearchProperties[Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDocument.PropertyNames.AbsolutePath] = AbsolutePath_Here;
        doc.SearchProperties[Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDocument.PropertyNames.ClassName] = "HtmlBody";
        doc.SearchProperties[Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDocument.PropertyNames.FriendlyName] = "Select People";
        doc.SearchProperties[Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDocument.PropertyNames.HasFocus] = "False";
        doc.SearchProperties[Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDocument.PropertyNames.Exists] = "True";
        doc.SearchProperties[Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDocument.PropertyNames.Enabled] = "True";
        doc.SearchProperties[Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDocument.PropertyNames.IsTopParent] = "False";
        doc.Find();
        doc.DrawHighlight();

上面的代码很容易突出显示人物选择器窗口,并使用此对象查找其中没有找到任何控件。

它显示此错误...

    The playback failed to find the control with the given search properties. Additional Details: 
TechnologyName:  'Web'
TagName:  'BODY'
FrameDocument:  'False'
RedirectingPage:  'False'
ControlType:  'Document'

我做对了吗。

4

1 回答 1

0

我找到了答案,.. 使用十字准线或录制将 peoplepicker 上的控件显示为单独的控件,但在通过代码查找时,其中的所有控件都显示为编辑框。因此需要将所有控件存储在 UITestControlCollection 中,并使用循环使用其 name 属性查找所需的控件。然后执行鼠标或键盘操作。

//write ur code here to find the parent control
UITestControlCollection controlFound = matching.FindMatchingControls();
//use loop to find the control
于 2013-02-04T08:56:24.053 回答