this is my very basic code (i'm trying automate some tests on an application and am using messagebox to display my progress thru the app) I get passed "here 3" but I get stuck further with an error below code
1.Is there a way to highlight all the controls within eventTab2 (or any object that I nominate?like some sort of recursive get?) and also return the type of object it is with all it properties?
2. Could you explain the solution above so I can manipulate it (remember newbie)
THANKS!!!
ERRoR
Test Name: CodedUITestMethod1
Test FullName: MSUItest.CodedUITest1.CodedUITestMethod1
Test Source: g:\CodedUITest1.cs : line 39
Test Outcome: Failed
Test Duration: 0:00:51.9135788
Result Message:
Test method MSUItest.CodedUITest1.CodedUITestMethod1 threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details:
TechnologyName: 'UIA'
FrameworkId: 'Wpf'
ControlType: 'TreeItem'
ClassName: 'MenuItem'
Search may have failed at 'windows' TabList as it may have virtualized children. If the control being searched is descendant of 'windows' TabList then including it as the parent container may solve the problem. ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
Result StackTrace:
at Microsoft.VisualStudio.TestTools.UITest.Playback.Engine.IScreenElement.FindAllDescendants(String bstrQueryId, Object& pvarResKeys, Int32 cResKeys, Int32 nMaxDepth)
at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindAllScreenElement(String queryId, Int32 depth, Boolean singleQueryId, Boolean throwException, Boolean resetSkipStep)
at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindScreenElement(String queryId, Int32 depth, Boolean resetSkipStep)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindFirstDescendant(String queryId, Int32 maxDepth, Int32& timeLeft)
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapControlNotFoundException(COMException ex, IPlaybackContext context)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowComException(COMException innerException, IPlaybackContext context)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, IPlaybackContext context)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, String queryId)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindFirstDescendant(String queryId, Int32 maxDepth, Int32& timeLeft)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetElement(Boolean useCache, ISearchArgument searchArg)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.Search(ISearchArgument searchArg)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindInternal()
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindControlIfNecessary()
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.DrawHighlightPrivate()
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.<DrawHighlight>b__36()
at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.DrawHighlight()
at MSUItest.CodedUITest1.CodedUITestMethod1() in g:\CodedUITest1.cs:line 76
1.Is there a way to highlight all the controls within eventTab2 (or any object that I nominate?like some sort of recursive get?) and also return the type of object it is with all it properties?
2. Could you explain the solution above so I can manipulate it (remember newbie)
THANKS!!!
var mainWindow1 = new WpfWindow(); mainWindow1.SearchProperties[WpfWindow.PropertyNames.Name] = "IntraBet [1.4.0.103] EQ3WNSTDB11"; mainWindow1.SearchProperties.Add(new PropertyExpression(UITestControl.PropertyNames.ClassName, "HwndWrapper", PropertyExpressionOperator.Contains)); mainWindow1.WindowTitles.Add("IntraBet [1.4.0.103] EQ3WNSTDB11"); mainWindow1.DrawHighlight(); var eventStack1 = new WpfCustom(); var eventStack0 = new WpfCustom(); var eventTab0 = new WpfTitleBar(mainWindow1); var eventTab1 = new WpfMenu(mainWindow1); var eventTab2 = new WpfTabList(mainWindow1); var eventTab3 = new WpfTreeItem(eventTab2); var eventTab4 = new WpfText(mainWindow1); MessageBox.Show("got here0"); eventTab1.SearchProperties[WpfMenu.PropertyNames.AutomationId] = "menubar"; eventTab1.DrawHighlight(); MessageBox.Show("got here2"); eventTab3.SearchProperties[WpfControl.PropertyNames.ClassName] = "MenuItem"; eventTab3.DrawHighlight(); MessageBox.Show("got here4"); eventTab2.SearchProperties[WpfTabList.PropertyNames.AutomationId] = "windows"; eventTab2.DrawHighlight(); MessageBox.Show("got here3"); eventTab0.SearchProperties[WpfCheckBox.PropertyNames.AutomationId] = "chkIncludeSetted"; eventTab0.DrawHighlight(); MessageBox.Show("got here1");
ERRoR
Test Name: CodedUITestMethod1
Test FullName: MSUItest.CodedUITest1.CodedUITestMethod1
Test Source: g:\CodedUITest1.cs : line 39
Test Outcome: Failed
Test Duration: 0:00:51.9135788
Result Message:
Test method MSUItest.CodedUITest1.CodedUITestMethod1 threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details:
TechnologyName: 'UIA'
FrameworkId: 'Wpf'
ControlType: 'TreeItem'
ClassName: 'MenuItem'
Search may have failed at 'windows' TabList as it may have virtualized children. If the control being searched is descendant of 'windows' TabList then including it as the parent container may solve the problem. ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
Result StackTrace:
at Microsoft.VisualStudio.TestTools.UITest.Playback.Engine.IScreenElement.FindAllDescendants(String bstrQueryId, Object& pvarResKeys, Int32 cResKeys, Int32 nMaxDepth)
at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindAllScreenElement(String queryId, Int32 depth, Boolean singleQueryId, Boolean throwException, Boolean resetSkipStep)
at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindScreenElement(String queryId, Int32 depth, Boolean resetSkipStep)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindFirstDescendant(String queryId, Int32 maxDepth, Int32& timeLeft)
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapControlNotFoundException(COMException ex, IPlaybackContext context)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowComException(COMException innerException, IPlaybackContext context)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, IPlaybackContext context)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, String queryId)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindFirstDescendant(String queryId, Int32 maxDepth, Int32& timeLeft)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetElement(Boolean useCache, ISearchArgument searchArg)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.Search(ISearchArgument searchArg)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindInternal()
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindControlIfNecessary()
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.DrawHighlightPrivate()
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.<DrawHighlight>b__36()
at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.DrawHighlight()
at MSUItest.CodedUITest1.CodedUITestMethod1() in g:\CodedUITest1.cs:line 76