Forum Discussion

joscva's avatar
joscva
Contributor
29 days ago
Solved

Suddenly unable to find WPFObject

Today I've been building a test case for a repetitive task I needed to plow through.  Everything was fine, it was working perfectly.  Then out of the blue, for no reason at all that I can see, one of the very first steps in the test began to fail due to WPFObject not existing.

I'm testing a WPF Desktop app, and it has a main menu called "Menu".  When clicked, it drops down to reveal other items including one called "Connections".  Within that, are various datafeed sources the user can select.

This is brain-dead simple, and it's a core component of many of the tests I've created.  I have never, ever, had it fail in the months I've ben working in TestComplete.  It works on Visual Studio source branches, and it works on compiled/obfuscated builds.  Never an issue, until now.

U stick to Keyword Tests at all times unless there is absolutely no other option.  I can manually record a test of me clicking Menu, then Connections, then a sub-menu item, and the result is an extremely simply Menu Action operation like this:

"MENU|Connections|[4]"

It doesn't get much simpler.  But now, out of nowhere, it just fails 100% of the time.  It doesn't even get to selecting Connections, which is where the failure is.  It clicks Menu, then just loops infinitely looking for WPFObject (until I kill it).

I thought maybe somehow there was something in the TC update I installed this morning before I began building the test, so I uninstalled and rolled back.  No change.

I thought maybe somehow something had gone wrong with the new build of our app that came out today, so I removed it and rolled back to what I began with this morning.  No change.

I thought maybe it was obfuscation related (we've seen strange things crop up occasionally due to it) so I ran from source.  No change.

Relaunched TC and our app several times, no change.

Rebooted my PC, no change.

I'm at my wits' end.  This worked perfectly, right up until the moment it didn't, and I hadn't changed anything between it working, and not working.  Anyone have any suggestions on what to do or look for here?

  • I almost can't believe it, but I seem to have fixed this issue.  Still stumped as to why it happened in the first place, but I'll attempt to explain how I seem to have fixed it.

    So the Menu Item I'm trying to select, "Connections", is an item in our object "Menu".  But for reasons unknown, it was no longer being able to be recognized, for no obvious reason.  Point & Fix couldn't select it either.

    But I was looking through the NameMapping and noticed that everything in the menu was below a node called "Popup".  I guess this is a WPF thing?  One of our devs explained it to me recently but I only vaguely grasped it.

    Anyway, this got me thinking... so I went to remap the object "Popup" (which was not locatable nor viewable in the Object Browser) but I wasn't sure what to select from the Spy.  I decided to highlight the boundary AROUND all the menu items (which was tricky as there's only a couple of pixels that cause it to select):

     

    As SOON as I did this, everything behaved again!  The Menu TC had previously recorded now works perfectly again:

     

    "MENU|Connections|[4]"

    And my variable version that generates it dynamically, also works perfectly:

    "MENU|Connections|[" + str(Project.Variables.Counter) + "]"

    Amazing.  So, at least now if this happens again, I'll have some idea of how to fix it.  I just wish I knew what on earth happened in the first place!

24 Replies

  • Hassan_Ballan's avatar
    Hassan_Ballan
    Icon for Champion Level 2 rankChampion Level 2

    I am trying to follow the conversation, desktop is not my specialty so I don't have a horse in this race; however, few things caught my eyes.

    Note: The only difference between KeywordTest and code based scripts is viewing operations visually versus reading code, and the KeywordTest can be converted into code script.

    1) Please confirm that you tried it in a new empty project. You only need to record and play back the two clicks "MENU|Connections". If it fails, wait for it to timeout (once I had to wait 20 minutes), and provide the log Details message and the Picture.

    2) Based on your statement "When I try, it highlights the Connections item in red but won't select it.", when you use the Spy option "Point and fix", are you also using (Shift+Ctrl+A) to select the highlighted in red?

    3) Rather than having a single operation to navigate the menu, can you attempt it in multiple operations

    Aliases.Tickblaze_View.Desktop.Menu.WPFMenu.Click("MENU");
    Aliases.Tickblaze_View.Desktop.Menu.WPFMenu.Click("Connections");
    Aliases.Tickblaze_View.Desktop.Menu.WPFMenu.Click("New Data Connection...");

    πŸ’¬ If a response helped you out, don’t forget to Like it! And if it answered your question, mark it as the solution so others can benefit too.

    • joscva's avatar
      joscva
      Contributor

      Appreciate your input.

      1. Yes, new empty project.  I'll do it again though and just walk away to see how long it takes to completely time out.  Will have to wait until I don't need to touch my machine for an extended period, so I don't know when I'll get to this.
      2. I can't use Ctrl-Shift-A as that is mapped to things in other applications, but I always change the hotkey to Ctrl-Shift-` (backtick) so the principle is the same.  I highlight it, and hit the hotkey, it then stays highlighted but nothing happens, and as soon as I click on anything else on the machine, the Spy operation ends and I'm faced with lots of "the object disconnected' messages in it.
      3. This is what I get:

        As usual, the second item cannot be clicked because it doesn't exist for some reason.

       

      • joscva's avatar
        joscva
        Contributor

        OK I let it go for over 22 minutes just failing to find the object, before I finally killed it.  Now it's just stuck on "Stopping..." and I have my doubts that it will recover.

         

  • scot1967's avatar
    scot1967
    Icon for Champion Level 1 rankChampion Level 1

    Hello joscva,

    There is a lot going on here.  The short of it is the menu automation has stopped working.

    • TestComplete has been updated and rolled back.
    • You are testing a new version of your application.

     

    I normally start by examining the suspect object with the spy tool and then use the record script option (instead of a keyword test) to record the actions and examine the script.

    It would also be useful to perform a source dif on this area of the new app version and on the TestComplete project to ensure no changes are noted.

    A new object inserted in the object tree can be the cause of many issues like this.  

    ... If you find my posts helpful drop me a like! πŸ‘ Be sure to mark or post the solution to help others out and/or to credit the one who helped you.  😎

    • joscva's avatar
      joscva
      Contributor

      Thanks, I don't really follow however.

      I have recorded as a script as well, and I get the exact same behavior.  Here is the script TC recorded:

      def Test1():
        Aliases.Tickblaze_View.Desktop.Menu.WPFMenu.Click("MENU|Connections|New Data Connection...")

      I tried to get it to click an item within the Connections section of the menu, but it can't because it never clicks Connections.

    • joscva's avatar
      joscva
      Contributor

      Thanks for replying.  Extensions are all installed, licensing is fine.

      Object Spy cannot select any item in the menu, using Point & Fix.  When I try, it highlights the Connections item in red but won't select it.  Once I click off then Object Spy recognizes that the object apparently doesn't exist, and Menu Action of MENU|Connections won't work. 

      However, If instead I click only Menu, then explicitly do a separate On-Screen Action click of Connections, it works fine, but then I'm still unable to select any of the items under the Connections sub-menu.

      • scot1967's avatar
        scot1967
        Icon for Champion Level 1 rankChampion Level 1

        I normally record a script from the performance of screen actions expected in these cases and then examine what TestComplete records.  In most cases TestComplete will record an X,Y click if it can't record the object path/identification.  This will tell you exactly what TC is not able to see or it will identify and record it and you can then modify your test accordingly.

  • I almost can't believe it, but I seem to have fixed this issue.  Still stumped as to why it happened in the first place, but I'll attempt to explain how I seem to have fixed it.

    So the Menu Item I'm trying to select, "Connections", is an item in our object "Menu".  But for reasons unknown, it was no longer being able to be recognized, for no obvious reason.  Point & Fix couldn't select it either.

    But I was looking through the NameMapping and noticed that everything in the menu was below a node called "Popup".  I guess this is a WPF thing?  One of our devs explained it to me recently but I only vaguely grasped it.

    Anyway, this got me thinking... so I went to remap the object "Popup" (which was not locatable nor viewable in the Object Browser) but I wasn't sure what to select from the Spy.  I decided to highlight the boundary AROUND all the menu items (which was tricky as there's only a couple of pixels that cause it to select):

     

    As SOON as I did this, everything behaved again!  The Menu TC had previously recorded now works perfectly again:

     

    "MENU|Connections|[4]"

    And my variable version that generates it dynamically, also works perfectly:

    "MENU|Connections|[" + str(Project.Variables.Counter) + "]"

    Amazing.  So, at least now if this happens again, I'll have some idea of how to fix it.  I just wish I knew what on earth happened in the first place!

    • rraghvani's avatar
      rraghvani
      Icon for Champion Level 3 rankChampion Level 3

      The reasons for me, asking you to get a screen shot of the Object Browser/Object Spy tool in a new project, is so that I can see whether WPFObject is being recognised by TestComplete. 

      WPFObject is being recognised by TestComplete, as highlighted.

      This will indicate that there's no issue with "Suddenly unable to find WPFObject", as your title indicates. The next diagnosis, is then to look at your Name Mappings, hierarchy. If TC is not able to recognise the parent name mapping, neither of the child name mapping will be recognised. You will have to find the offending parent, and fix the name mapping! And finally, the wrong method could be generated to interact with the object.

      This is similar to post Unable to access popup menu from MFC Ribbon Dropdown button | SmartBear Community . I would also suggest not to use Point and Fix or Self-Healing mode as it could ruin name mappings hierarchy!

      I highly recommend you read through Object Identification, and Object Browser as it help you understand how TC works and to diagnose and fix issues.

      Also, if you can, avoid using indexes i.e. "MENU|Connections|[4]" - replace [4] with the a string name instead. As indexes can change!

      The "new" forum layout is not great at all!

      • joscva's avatar
        joscva
        Contributor

        Thanks I'll review the links you suggested.

        In this case, an Index is far better since I simply need to iterate through the entire list, whatever is there.  I don't care what the items are, or their order, etc.  I just have to run through each and every one of them.  But certainly if I was needing to select a specific item, relying on an Index is not a great idea.

    • scot1967's avatar
      scot1967
      Icon for Champion Level 1 rankChampion Level 1

      Great!  I am glad you figured it out.  I was close in my 1st reply given what I knew.  πŸ˜‰

      A new object inserted in the object tree can be the cause of many issues like this.