我正在尝试自动化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'
我做得对吗。
答案 0 :(得分:0)
我找到了答案,... 好吧,使用十字准线或记录显示对peoplepicker的控制作为separeate控件,但在查找代码时,其中的所有控件都显示为编辑框。 所以需要将所有控件存储在UITestControlCollection中并使用循环来查找使用其name属性所需的控件。 然后执行鼠标或键盘操作。
//write ur code here to find the parent control
UITestControlCollection controlFound = matching.FindMatchingControls();
//use loop to find the control