Forum Discussion

GabrielHabib's avatar
GabrielHabib
New Contributor
9 years ago

How to Map a JS Element

Hello, I'm having some trouble when trying to map some features from my WebSite. Actually, if I start capturing a moviments in my webSite the TestComplete doesn't recognize at all lots of screens. What I decided to do was trying to map some elements and once I know them, I while waiting them appear, or desappear... Well, I was going good till I reach this part :

 

 

I couldn't find a way to map the "Loading". I could use Delay in stead of waiting the page to be charged, but I don't want to tie up my test with lots of delays.

  • baxatob's avatar
    baxatob
    Community Hero

    Did you try to refresh object browser before mapping?

    • Colin_McCrae's avatar
      Colin_McCrae
      Community Hero

      When you say you can't find a way of mapping it, do you mean:

       

      1. It does not appear in the object browser. At all.

      2. You can't find any properties to identify it reliably.

       

      I presume this is a transient object? ie. it only exists while loading is happening and is not present in the DOM at any other time? (rather than just being hidden) Objects like this can be a little awkward to work with. The CTRL+SHIFT+A mapping method is usually your friend here ....

      • GabrielHabib's avatar
        GabrielHabib
        New Contributor

        I can't find any properties to identify it reliably.

         

        You are right, this is transient, well, I tried to work with CNTRL SHIFT A, but look to the image, it says the object doesnt exist :(

         

         

         

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    You may consider slightly different approach: I am taking that this 'Loading...' frame is displayed while the underlying Customers table is populated with data. If the above is correct, you may try this:

    -- Identify the Customers table;

    -- Wait until its number of rows is greater than zero and do not change within, say, a second. When this condition is met, this means that the table was populated with data and data are no more added to the table (in case this is done via some script and requires some complex processing).

    -- The above point assumes that if the table does not contain data at all, this is indicated somehow and can be identified from test code.

    • GabrielHabib's avatar
      GabrielHabib
      New Contributor

      Hello Alex, I appreciate your answer, however, the point is, as soon as I log into the system the table is automatically filled, and when I change the tab the system re fill the SAME table. In this case, I would wait two "loadings", but the number of elements(rows) would be same, less, bigger.... Well, I do agree I could use Delays, however, sometimes the system gets 5 seconds, others it gets 50secs....

       

       

       

      • Colin_McCrae's avatar
        Colin_McCrae
        Community Hero

        Your screen capture with "Object does not exist" refers to an Alias? Which would imply you already have a mapped object for it ... which doesn't work properly?

         

        In which case, can you delete the current mapped object (which doesn't work - so no loss).

         

        Then do a CTRL + SHIFT + A object spy (make sure you spy it, not map it - although I'm not sure it should make a difference) on it again. This should capture the properties at the point you map it. Even if it vanishes after that, you should still have the properties that were present when you spied it.

         

        Don't try and drill down within any of the properties, that will probably cause it to lose/clear the object.

         

        Do that, and then post the properties here.

         

        I'm thinking you could .....

         

        1. Simply put it in a double loop as soon as you activate whatever triggers it. One (very fast repeating) loop until it spots it. Then a second loop that waits for it to go.

        2. Identify it by something simple such as classname (assuming there are no other elements in the DOM of the same class).

        3. If using 1 &2, I would probably do all this dynamically and not map it.

        4. If you *really* need to map it, your best bet is likely the caption (if it's text) or the image file name (if it's an image and the filename is exposed in the properties somewhere).

         

        Without the element to look at ourselves, it's tricky to say.