Forum Discussion

olegOz's avatar
olegOz
New Contributor
8 years ago

I'm not able to map an object using Object Spy hence I cannot run a test. It fails - object not foud

Hello,

 

Could some please help/advise on how can I map an object or click on an object that cannot be mapped using ObjectSpy tool. Is there a way to do this with Xpath or CSSSelector if the object cannot be mapped using Spy tool. By hovering a mouse on the object I need, it will not be highlighted, hence it cannot be mapped/stored.

 

Please advise.

 

Thank you,

- Oleg

 

6 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Especially for Web applications, I find using Object Spy or the NameMapping tool tricky to get the EXACT right object...  In those cases, where I get a bit lost in all the divs and panels and whatnot, do a quick recording of the action and see what TestComplete finds in that.

     

    Without knowing more about the component that you are referencing, that's the best help I can give you beyond going to the TestComplete object browser and drilling down until you find it yourself.  It's entirely possible that it's a custom component that doesn't natively map in TestComplete and you may have to do so some other work with it... but I'd be willing to bet that a quick recording will find what you need, at least as a starting point.

    • olegOz's avatar
      olegOz
      New Contributor

      Thank you for your quick response.

       

      Please see the mock-up that is very similar to what I am having difficulties with: https://jsfiddle.net/ahLsqe65/

      The only difference is that I can record and replay on the mock-up and the button will be clicked. The objectSpy tool is not working on both. 

       

      The wab page that I do my testing on, if I perform record and replay, the object will not be found at the Replay time.

       

      Thank you for your help,

      - Oleg

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        Hi Oleg,

         

        SPAN objects show up in Object Browser / Object Spy only if they have a non-presentational role or their own text content. Please refer to Web Elements Included in and Excluded From the Tree Model.

         

        The button in your JSFiddle mock is actually spyable because it has text content: <span id="btn" class="...">Button</span>. On a side note, JSFiddle uses frames so you need to launch Chrome with these additional parameters to be able to spy on objects inside frames:

         

        --disable-web-security --user-data-dir

        Could you maybe share your actual web page? If you can't share it publicly, you can open a support ticket to share details with our Support team privately.

         


        olegOz wrote:

        Is there a way to do this with Xpath or CSSSelector if the object cannot be mapped using Spy tool.


        Yes, FindChildByXPath and QuerySelector can be used to access any elements in the Document Object Model (DOM), even those that do not show up in TestComplete Object Browser. Of course, DOM objects without a TestComplete wrapper only have methods and properties provided by the DOM and don't have TestComplete-specific methods .Click(), .Keys(), .HoverMouse(), etc. For example, you may be able to click a DOM element by using the native .click() method but the native click behavior is up to the browser.