locked
CodedUI based test throws UITestControlNotFoundException RRS feed

  • Question

  • We are trying to automatically test a WPF- based UI using CodedUI. The recorder creates an UIMap, but when the test runs, the following exception is raised:

    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:  'Window'
    Name:  'Otl.Ui.ViewModels.WizardMainPageViewModel'
    ClassName:  'HwndWrapper'
     ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component

    How can we troubleshoot this?


    Tuesday, January 23, 2018 4:49 PM

Answers

  • Hi DanV-SWE,

    I can repro you issue in my side.

     

    After my research, it could identify the 'Otl.Ui.ViewModels.WizardMainPageViewModel' window use coded UI test builder, but that window was not recognized during playback.

    I check other control about OfficeTIMELINE, I got the same error.

    In addition, based on the official documents describes, coded UI cannot test Office Client Application.

    https://docs.microsoft.com/en-us/visualstudio/test/supported-configurations-and-platforms-for-coded-ui-tests-and-action-recordings#platform-support

    So, I’m afraid that coded UI test also cannot test OfficeTIMELINE extension.

    Thanks for your understanding.

    Regards,

    Judyzh


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Judy ZhuY Tuesday, January 30, 2018 10:25 AM
    • Marked as answer by DanV-SWE Wednesday, January 31, 2018 9:52 AM
    Tuesday, January 30, 2018 10:25 AM

All replies

  • Hi DanV-SWE,

    Welcome to the MSDN forum.

    Are you playing a recorded test on the same machine?

    Which specific step failed while playing back the test?

    If you use the Drawhighlight() function for this control, could you see a blue boundary over this test control?

    Generally, the error message means that it couldn’t find the control with the search properties provided in the UIMap.

    If possible, I suggest you could record the same steps and playback it again. You could also use Coded UI Test Builder to verify that the search properties of the control in the UIMap, and make sure that they are matching with actual properties of the control. Usually, we would add the unique properties as the search properties.

    In addition, please make sure there is not the UI loaded issue, please add a wait event for it.

    Reference: https://blogs.msdn.microsoft.com/tapas_sahoos_blog/2011/11/06/troubleshooting-record-and-playback-issues-in-coded-ui-test/

    If above method not helpful for you, please share us a screen shot about your UI controls, maybe we could understand it better.

    Thanks for your understanding.

    Regards,

    Judyzh


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 24, 2018 6:02 AM
  •  - Yes, we are playing the recorded test on the same machine

    - the step was

                // Click 'Close' button
                Mouse.Click(uICloseButton, new Point(41, 25));

    - the DrawHighlight() call fails with the same error message

    - we've tried to call WaitForControlExists, the call timeouts

    - three developers have tried so far to record this simple script (we're evaluating different solutions for automating our testing process) and I've re-recorded it multiple times as well

    - we've also tried to set unique properties on the window, like x:Name, AutomationProperties.Name, AutomationProperties.Id

    - we've inserted Playback.Wait calls throughout the script

    I am trying to send you a screenshot, but the web page says "Body text cannot contain images or links until we are able to verify your account.". What do I do?

    Wednesday, January 24, 2018 11:17 AM
  • Hi Danv-SWE,

    You could share the screenshot via OneDrive, please upload the screenshot to https://onedrive.live.com/  and share the link here.

    >> Mouse.Click(uICloseButton, new Point(41, 25));

    This means that the CodedUI is trying to click on a close button using a specific point on the screen. For some reason it is unable to find the button it wants to click. Does the button appear on the window which name is “Otl.Ui.ViewModels.WizardMainPageViewModel”?

    Please first make sure find the window and Drawhighlight() it, before click the button. You could use the cross-hair in Coded UI Builder to locate the window on screen and then check its search properties. Then, use the search properties that get from the Assertions window to find the window in your WPF application. Please refer to the sample code below:

    WpfWindow window = new WpfWindow();
    
                window.SearchProperties.Add(WpfWindow.PropertyNames.ControlType, "Window");
    
                window.SearchProperties.Add(WpfWindow.PropertyNames.Name, "Otl.Ui.ViewModels.WizardMainPageViewModel");
    
                window.SearchProperties.Add(WpfWindow.PropertyNames.FrameworkId, "wpf");
    
                window.DrawHighlight();
    

    In addition, if it’s OK, please share the wpf application via OneDrive, it could help us test it and find the solution of your issue.

    Thanks for your understanding and cooperation.

    Regards,

    Judyzh

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, January 25, 2018 6:14 AM
  • I've uploaded the test script project at https://1drv.ms/u/s!AixfUG56ikKRdHRtqyjYcfQFjy0.

    There's only one test, that opens and closes one WPF-based dialog. It records fine, but during playback it fails with the error I've already mentioned.

    Please download the application from https://www.officetimeline.com/Content/download/OfficeTimeline.exe (it is a PowerPoint add-in that shows some WPF-based dialogs); the Free edition does not require you to purchase a license. The setup will automatically install Microsoft Visual Studio Tools For Applications (VSTO) Runtime and .NET Framework 4.5.2, if needed.

    Thank you for your help.

    Thursday, January 25, 2018 8:15 AM
  • Hi DanV-SWE,

    I can not run your project in my side with application OfficeTimeline.exe.

    I checked your code in your project, you test the POWERPNT.EXE under location “C:\Program Files (x86)\Microsoft Office\Office16”, not OfficeTimeline.exe application. I need more information to confirm what you're testing.

    In addition, I suggest you try to create the code via hand-coding, refer to my suggestion in previous reply.

    Thanks for your understanding.

    Regards,

    Judyzh


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, January 25, 2018 9:46 AM
  • Like I said above, our "application" is actually a PowerPoint add-in. In order to test it, the script launches PowerPoint.


    Thursday, January 25, 2018 1:26 PM
  • Maybe you misunderstood: the OfficeTimeline.exe is the setup for our add-in: when you run it, it will install the add-in. Then you can use the script that opens PowerPoint and then tries to automate a WPF-based dialog in our add-in.
    Monday, January 29, 2018 12:32 PM
  • Hi DanV-SWE,

    I can repro you issue in my side.

     

    After my research, it could identify the 'Otl.Ui.ViewModels.WizardMainPageViewModel' window use coded UI test builder, but that window was not recognized during playback.

    I check other control about OfficeTIMELINE, I got the same error.

    In addition, based on the official documents describes, coded UI cannot test Office Client Application.

    https://docs.microsoft.com/en-us/visualstudio/test/supported-configurations-and-platforms-for-coded-ui-tests-and-action-recordings#platform-support

    So, I’m afraid that coded UI test also cannot test OfficeTIMELINE extension.

    Thanks for your understanding.

    Regards,

    Judyzh


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Judy ZhuY Tuesday, January 30, 2018 10:25 AM
    • Marked as answer by DanV-SWE Wednesday, January 31, 2018 9:52 AM
    Tuesday, January 30, 2018 10:25 AM
  • Microsoft used to be a technology-oriented company. It still is, but in many areas is just another sad enterprise, with sad, unhappy, unhelpful people. I would have expected a solution instead of an excuse.

    Let's just close this discussion, it's worthless, sad and disgusting.

    • Edited by DanV-SWE Thursday, February 1, 2018 7:57 AM
    Wednesday, January 31, 2018 9:52 AM