Unable to locate element error when automating WPF application

12 posts, 0 answers
  1. Alex
    Alex avatar
    6 posts
    Member since:
    Sep 2014

    Posted 25 Sep 2014 Link to this post

    Hi,

    We're having issues with running tests for WPF application. Tests created on one computer don't run on another computer with error "Unable to locate element. Search failed!".

    When updating failing test on another computer I even get different XamlPath for the same element. Original path on first computer was:
    [name 'Exact' PART_ItemsHolder] AND [XamlTag 'Exact' grid][XamlPath 'Exact' /contentpresenter[1]/grid[0]/grid[0]/textbox[1]/border[name=border]/scrollviewer[name=PART_ContentHost]/grid[0]/scrollcontentpresenter[0]/textboxview[0]]

    Updated path on another computer:
    [name 'Exact' PART_ItemsHolder] AND [XamlTag 'Exact' grid][XamlPath 'Exact' /contentpresenter[1]/grid[0]/grid[0]/textbox[1]/listboxchrome[name=Bd]/scrollviewer[name=PART_ContentHost]/grid[0]/scrollcontentpresenter[0]/textboxview[0]]

    I marked different paths with bold. Path until bold is OK and TestStudio was able to find target element when resolving failure. However, after resolving and saving the test it fails on first computer.

    What are we doing wrong?
  2. Alex
    Alex avatar
    6 posts
    Member since:
    Sep 2014

    Posted 26 Sep 2014 in reply to Alex Link to this post

    In case anyone will face the same issue - I found a source of it.
    On different computers we had different Windows themes (I had Aero and another computer was in classic theme) - both computers run on Windows 7. After switching to classic theme everything worked. However, I have a question to Telerik support - can anyone please tell me how to bypass this issue? I'm pretty sure that on Windows 8 this test will fail. Switching back and forth Windows theme is an option but quite inconvenient. Also, I think this behavior should be explicitly noted in documentation somehow (or I just didn't search properly).
    So my question will be: how do I specify path that will ignore some elements? I'd like to be able to specify in XamlPath something like XPath "//" i.e.:
    [name 'Exact' PART_ItemsHolder] AND [XamlTag 'Exact' grid][XamlPath 'Exact' /contentpresenter[1]/grid[0]/grid[0]/textbox[1] // scrollviewer[name=PART_ContentHost]/grid[0]/scrollcontentpresenter[0]/textboxview[0]]
    (note double // in the path).

    Thanks in advance.
  3. Anna
    Anna avatar
    2 posts
    Member since:
    Oct 2010

    Posted 29 Sep 2014 Link to this post

    Hello Alex, hello Telerik team!

    Unfortunately, I have faced with the same problem during testing of my Silverlight app, and found the same option - to change Windows themes. Would like to join Alex and wonder if there is a better way to avoid such kind of problems?

    Thank you!
  4. Boyan Boev
    Admin
    Boyan Boev avatar
    1072 posts

    Posted 30 Sep 2014 Link to this post

    Hi,

    Unfortunately we have never seen such a behavior. In order to assist you best we need to reproduce this locally so we can debug what is causing this issue.

    Could you please (Alex or Anna) grant us a direct access to your application (give us the WPF application or a sample one) where we can replicate this and give you a solution.

    Hope to hear from you soon.

    Regards,
    Boyan Boev
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  5. Alex
    Alex avatar
    6 posts
    Member since:
    Sep 2014

    Posted 30 Sep 2014 in reply to Boyan Boev Link to this post

    Hi,

    Thanks for your attention to this issue. I need to contact my client about how we can provide application for Telerik and get back to you as soon as possible.
  6. Alex
    Alex avatar
    6 posts
    Member since:
    Sep 2014

    Posted 02 Oct 2014 in reply to Boyan Boev Link to this post

    Hi Boyan,

    I prepared a sample application which reproduces our issue. Attached archive contains two folders: WpfApp (sample app with source code) and TestStudio (test project). Please rebuild application in Visual Studio before running test. Steps to reproduce:
    1) Run test from test project while being in any Windows 7 Aero theme - it should pass
    2) Switch to classic Windows theme and run test again - it should fail on second step

    Please let me know if you more information from my side.

    Thanks!
  7. Anna
    Anna avatar
    2 posts
    Member since:
    Oct 2010

    Posted 02 Oct 2014 Link to this post

    Hi Alex,

    Could you please clarify: using what theme you get your tests failed - on Aero or Classic one? My tests fail using Aero and successfully pass on Classic. And what is your case?

    Thank you!
  8. Alex
    Alex avatar
    6 posts
    Member since:
    Sep 2014

    Posted 02 Oct 2014 in reply to Anna Link to this post

    Hi Anna,

    On my computer things are different: test passes on Aero and fails on Classic. Quite strange that you got different results. I hope Telerik engineers will bring some light to this issue.
  9. Boyan Boev
    Admin
    Boyan Boev avatar
    1072 posts

    Posted 03 Oct 2014 Link to this post

    Hello Alex,

    Thank you for the sample application. I was able to reproduce the issue.

    It seems that the issue is coming from your custom tab control (TabControlIE.cs). What is this customization doing exactly?

    I have replaced your tab control with the default one TabConrol and re-record step 2. The test is now able to execute in any kinds of theme and Windows.

    Please find attached the project.

    Hope this helps. 

    Regards,
    Boyan Boev
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  10. Alex
    Alex avatar
    6 posts
    Member since:
    Sep 2014

    Posted 03 Oct 2014 in reply to Boyan Boev Link to this post

    Hello Boyan,

    Unfortunately, without TabControlEx templates for TabControl don't work and I can't see tab items. Interface in our application is based on tabs with custom templates so this is important functionality for us.
    For now I found how to bypass this issue - I can force classic theme for the application. But in order to do that I need Test Studio to pass parameters to my application via command line. Could you please tell me if it's possible to do or not?
  11. Ivaylo
    Admin
    Ivaylo avatar
    782 posts

    Posted 08 Oct 2014 Link to this post

    Hello Alex,

    Boyan will be updating this ticket shortly.

    Thank you for your patience and understanding.

    Regards,
    Ivaylo
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  12. Boyan Boev
    Admin
    Boyan Boev avatar
    1072 posts

    Posted 09 Oct 2014 Link to this post

    Hi Alex,

    Please excuse me for the delayed replay.

    You can easily workaround this behavior by changing the find expression of the element. Please remove the XAML path from the find rules and use some other one (e.g. automation ID, text content e.t.c).

    Let me know if this works for you.

    Regards,
    Boyan Boev
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top