Forum Discussion

ratner's avatar
ratner
Occasional Contributor
10 years ago

"Object does not exist" problems

I'm having a problem with clicking a button inside my application. When I playback my test, TestComplete comes back with "object does not exist" error message, even though the button is clearly there. When I use On-Screen Action dialog, I can find the button with the object spy. I can click on "Highlight", which highlights it in my app. However, after I close On-Screen Action dialog, re-open it again, and click Highlight, I get "Unable to highlight selected object on the screen". I'm beating my head against the wall, but I can't seem to be able to figure out what the problem is here. Any suggestions? Thanks in advance.

10 Replies

  • NisHera's avatar
    NisHera
    Valued Contributor
    Hi,

    You hvn't mentioned what type of appilcation you are testing and how does your name mapping has done. However I also faced same situation when I started with test compleate.



    First, pleace check the object does having dynamic name ....something like ..dlgWarning2  (number could be dynamically assigned)

    or check how you have the object mapped with name mapping  is it ambiguous?

    or dose same object has two mappings (one you have manually mapped and you have checked auto mapping option ticked )



    try comparing what you have mapped and what object spy detect when identification failed.





  • m_essaid's avatar
    m_essaid
    Valued Contributor
    hi,



    just an idea, but don't you have to define as "tested app" the two executables ?

    After you could specify by the syntax "Aliases.TestedAppX...." ?



    Mehdi
  • amathews's avatar
    amathews
    Occasional Contributor
    NameMapping is for squares.  Descriptive programing ftw!

    proc = "firefox"

    Sys.Process(proc).Find(["ObjectType", "ObjectIdentifier"], ["*Button*", "buttonName"], 99);
  • ratner's avatar
    ratner
    Occasional Contributor
    Hi. Thank you all for replies. I'm a complete noob to TestComplete (have been using it for just few weeks), and I still can't resolve this issue. The application that I'm testing is written in Microsoft .NET. The button has a dynamic name. I can open it in Name Mapping Editor, but this is where I'm having difficulties. No matter what I do, when I playback my test TestComplete cannot find it. I'm having a similar issue with a navigation bar that's divided into several "breadcrumbs". I record my test, play it back, and it fails to find the object. Very, very frustrating. All I'm doing at this point is trying to get from point A to point B in the UI. Nothing fancy, just clicking on buttons/bars/menus/etc... I would greatly appreciate any pointers, or if anyone lives in Greater Rochester Area (Western NY), and doesn't mind to meet me for a brief TestComplete demo, lunch/beer is on me :-) . Once again, thank you in advance for all the help.
  • Marsha_R's avatar
    Marsha_R
    Champion Level 3
    Hi Vlad - 



    Does the button have a label or some other property that doesn't change?  



    For the breadcrumbs, you may be able to find an index that lets you traverse the tabs by number.



    I'd take you up on the lunch/beer offer, but you'd have to throw in a plane ticket from California.  ;)
  • ratner's avatar
    ratner
    Occasional Contributor
    "Does the button have a label or some other property that doesn't change? "



    I'm not sure... how do I check that?

    It's interesting though that only inside the wizard that it doesn't work (it's using Lua engine, which could be the problem). When I use the same button in a standalone page, it works just fine.




    "For the breadcrumbs, you may be able to find an index that lets you traverse the tabs by number."

    You lost me here... What do you mean exactly, and how do I do it? I'm gonna attach a screenshot which might explain better what I'm trying to do.



    ... maybe I should take a trip to California instead :-) .



  • ratner's avatar
    ratner
    Occasional Contributor
    So originally I was on Step 1 page. I clicked on FCM Target Settings button inside Step 1 page. It took me to FCM Target Settings Page. Now I want to get back to Step 1. All very simple, just point and click when I record my test with TestComplete, but it comes back with "Object not found..." message every time. I wonder if it's because the whole Navigation Bar is treated as one object, and how do I get around it. Thank you.
  • Marsha_R's avatar
    Marsha_R
    Champion Level 3
    "I wonder if it's because the whole Navigation Bar is treated as one object"

    That's very likely the issue here...



    "and how do I get around it"

    Well...





    I want to click on the tab called "Header"               header.png


    I name map the tabs line                                          namemapping.png



     


    Now to find the tab



    • Use ObjectSpy on the tabs line                                          objectspy1.png


    • Switch to Advanced mode to get more properties           objectspy2.png


    • Scroll down through the list and look for something that might be a collection of objects.  In my case, VisibleTabs looked like a good choice.  Click on the button on the right with the three dots to expand the property.                                objectspy3.png


    • Look for something with a Params button, in this case, Index, and click on the Params button                                                                                        objectspy4.png


    • Index may have a number or a text entry or both.  In this case, we need an integer.  "Header" is the first tab, so index for this one is 0.  Enter that in the box and you will see it on the property.                                                                         objectspy5.png


    • Next click the three dots button on the right and see what you can find out about Index(0).  The text property = Header, so we're almost done.               objectspy6.png


    • Drill down on the three dots again and find OleValue property that says Header.  That's the actual text inside the object.  Click on that.  objectspy7.png



    Now you'll find a long definition up in ObjectSpy that ends in OleValue.  Copy it and save it in notepad or somewhere for later reference.

     


    In my test example, I used:  


    If (object property BigLongOleValue) = "Header" Then 


    OnScreenAction (object we mapped at top)   ClickTab   index = 0


    test.png

     


    and magically it clicks the tab!

  • ratner's avatar
    ratner
    Occasional Contributor
    Thank you for a very detailed reply. Unfortunately, I'm still having difficulties. First, when I try to map the object, I get an error sayint that it's already mapped. Then, when I use the object spy, the only property object with Params button that I found is DataBindings, which doesn't seem right. When I try to change index to 1 (which is the 2nd breadcrumb in my navigation bar), I'm getting "Index out of range" error message. I'm stuck at this point, and don't have any other ideas on how to proceed. Any help is greatly appreciated.
  • Hey Vlad,

     

    I've faced a similar problem with one of my applications, due mostly to the need to support legacy Janus controls. What I ended up doing was mapping the menu items as children of the menu bar, then calling a helper function to discover them in the future. I don't know if it will help you, but here are my steps:

           1. Identify the top-most menu

            2. Use MenuCrawler() to print the children to the Log

           3. Use the log to create a reverse-lookup

           4. Use the reverse lookup to create a click method     

     

    This method is chalk full of potential pitfalls, but for my particular situation this method was a good jumping off point. Good luck out there.

     

    - Howie

     

     

     

     

     

    function MenuCrawler()

    {

           //put in the name of the top-most menu

           GetSubMenu(Aliases.<Product>.Form.UICtrlsMainMenu, "[");

    }

     

    //this method recursively searches for child menu items

    function GetSubMenu(menu, prefix)

    {

           if(menu == null) { return; }

     

           var count = menu.Count;

           if(count == null || count <= 0){ return; }

     

           for(var i = 0; i < count; i++)

           {

                  Log.Message(prefix + i + "] :: " + menu.Items(i).Caption); //this might need to be ".Text" or ".Content" depending on the circumstances

           

                  GetSubMenu(menu.Items(i).SubMenu, prefix + i + "|");

           }

    }

     

    /* Some sample log output:

    [0] :: File

    [0|0] :: New

    [0|1] :: Save

    [0|2] :: Quit

    [1] :: Help

    [1|0] :: Contact

    [1|1] :: About

    */

     

    //new lookup method:

    //this method returns the whole control, in case you need ".Enabled" or ".Visible" and whatnot

    function FindMenuItem(path)

    {

           var menu = Aliases.<Product>.Form.UICtrlsMainMenu;

           switch (path)

           {

                  case "File" :         return menu.Items(0);

                  case "File|New" :     return menu.Items(0).SubMenu.Items(0);

                  case "File|Save" :    return menu.Items(0).SubMenu.Items(1);

                  case "File|Quit" :    return menu.Items(0).SubMenu.Items(2);

                  case "Help" :         return menu.Items(1);

                  case "Help|Contact" : return menu.Items(1).SubMenu.Items(0);

                  case "Help|About" :   return menu.Items(1).SubMenu.Items(1);

                  default: return null;

            }

    }

     

    //this method specifically clicks on the button in question

    function ClickMenuItem(path)

    {

           FindMenuItem(path).Click();

    }