Forum Discussion

jdwather's avatar
jdwather
Contributor
7 years ago

How to record test in application using XAML

Hello,
I'm starting a new project, where the application I'm going to test uses XAML and the developers do not name the components in XAML. When writing the test with TestComplete, the mapping saves two different fields in the application with the same name in the mapping, because the components have no name defined in XAML. Has anyone ever encountered this situation and got a solution?

4 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    Any chance to convince developers to assign a unique and stable identifiers to the objects that your test needs to interact with?

    If not, may it help to demonstrate the problem to the management and wonder whether they prefer a long time to create each test or whether they prefer unstable and hardly maintainable tests or whether they have some other preferences (with fast reliable tests been not an option to be even considered) ?

    You should explain that your problem is not specific to TestComplete but is generic to any tool that performs functional automated testing from the end-user point of view. The case is that tool needs to be able to identify the UI element before interacting with it. And the most efficient way for this are unique identifiers assigned to each and every UI element that needs to be interacted with.

    The above is one of the major differences between functional testing and unit testing done by developers. In case of unit testing (as well as for the application itself) it is normal and possible that some code has no idea about its caller. For example, some function can be set up as a handler for some event triggered by different controls. And it is highly possible that it is absolutely irrelevant for this function what control called it.

    Approach like this will not work for UI testing. Like the human user cannot 'just enter data' or 'just click button' but needs to identify the correct UI element first, likewise the UI automation test tool needs to identify the target control before interacting with it.

    In the worst case, if neither Development not Management agree to spent some efforts to create a more accessible and better testable application, you almost only option might be to search the required UI element by the text it contains. This will be not fast and not very reliable, but might work.

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      In addition to what AlexKaras has discussed, have you investigated what other properties are available on the object?  Alexei mentioned contentText (or textContent) as one possibility but there may be others.  The properties TestComplete assigns are just suggestions...  99.999999% of the time (Ok... I exaggerate, but only a little) it is a best practice to edit the properties that TestComplete uses auto-magically and select ones that work best for your situation.  

    • jdwather's avatar
      jdwather
      Contributor

      Thanks for reply, I've talked to the development team and they will change all screens by adding name to the XAML components. Thank you for your help.

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        Great to hear this. Development team ready to listen for the requests from Testing and willing to help is the best possible option, I think.