Forum Discussion

KrzysztofLach's avatar
KrzysztofLach
New Contributor
2 years ago
Solved

loosing mapped web object

Hi,

The parent web object in Name Mapping has prepared declaration:

.class11.class12:not(.class13) > .class21

Similar example css setting there are at first picture here => https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/selectors.html .

 

My Keyword Test uses this mapped object in a loop.

It works during first run properly but in the second turn I getting error of unrecognized child object (because above described parent is unrecognized) with the log message below:

The window size is (0, 0); the screen rectangle: the left top corner is (0, 99), the right bottom corner is (0, 99).
 
I may change unrecognized status manually by unmark and then mark again mapped declaration. After then, it can recognize parent mapped object by "Highlight" menu order (and of course child too).
 
What I may do for improve this situation ?
 
For explanation - HTML code I work for has parent object declaration lines like below:
<parent1 class = class1 class2 class3 name=... >
<parent1 class = class1 class2 name=... >
...
<parent1 class = class1 class2 class3 name=... >
 
I must indicate this one parent object which has no class3
Test Complete is mapping this object as .class1:nth-child(<nr>) during recording Keyword Test. It isn't proper because in the next turn loop of Keyword Test the number <nr> of chosen position nth-child is changing dynamically (besides the web page looks identically).
  • AlexKaras's avatar
    AlexKaras
    2 years ago

    Great to hear that the problem is solved.

    Actually, .RefreshMappingInfo() method is mentioned in the documentation article that you referenced in your initial message 😉

    Just as a side note: TestComplete provides a really good, correct and descriptive documentation that definitely worth detailed reading.

     

6 Replies

    • KrzysztofLach's avatar
      KrzysztofLach
      New Contributor

      Is Regular Expressions and Wildcards only option in that situation ?

      Is it the proper/expected behavior of Test Complete ?

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Regular Expression or Wildcards will most likely resolve the issue.

     

    It's the expected behavour with programming languages that follow object oriented programming

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    The window size is (0, 0);

    Knowing no details about your given tested application, this sounds to me like one of the usual problems caused by poor tested application design/implementation.

    Scenario been guessed is like this:

    -- Your test code gets a reference to the object (A) before entering the loop;

    -- Test code does something on the first loop iteration. As a result of this action, object A must be modified within the tested application. But tested application neither modifies object A, nor deletes it from the DOM. Instead, tested application hides object A by setting its width/height to zero and creates a new object (A1) that is identical to initial object A. (Actually, this is a resource leak, because object A remains in DOM and consumes resources but is never used from now on.);

    -- Now your test code moves to the second loop iteration and tries to reuse object A. The object still exists, thus its reference remains valid and you do not get 'Object Not Found' error, but action (like .Click() ) over this object is not possible because of its zero size and this causes the message that you see in test log.

     

    Try to investigate tested page in the Object Browser after first loop iteration and check if width/height of initial object A are zeroed indeed. If they are, then search for the sibling object (A1) that is identical to object A but is visible (i.e. has its width/height positive). If you find such object this will mean that my guess is correct.

    If my guess is correct, then you have two options:

    -- Report resource leak to Development and insist on the fix. To say the truth, I do not believe in this option - who cares about resources nowadays? 😞 

    -- Your second option is to add additional criterion in NameMapping to make it search for the object of non-zero size and move object search inside the loop, so TestComplete will re-evaluate the reference to the object on every loop iteration and will use correct newly created object (A1, A2, ...) for the actions performed within the loop.

     

    Hope this will help...

     

    • KrzysztofLach's avatar
      KrzysztofLach
      New Contributor

      Thanks a lot AlexKaras for your wide answer - I appreciate.

      I can't report this problem to Development. This part source code have been realized by another company and it can't be modify. It works properly and this is my problem - how prepare testing in this environment for modifying part application only.

      You see, it's politically complicated. 🙂

       

      For explanation - in HTML code all the parent object declarations (like below) are permanently exists.
      <parent1 class = class1 class2 class3 name=... >
      <parent1 class = class1 class2 name=... >
      ...
      <parent1 class = class1 class2 class3 name=... >
      The name of class3 is "ng-hide" - it may help more explains this specific situation.

       

      But I hope, I found resolving but please, be patient.

      I want to indicate my previous insight:

      I may change unrecognized status manually by unmark and then mark again mapped declaration. After then, it can (proper) recognize parent mapped object by "Highlight" menu order (and of course child too).

       

      At the beginning, I have prepared other Keyword Test with loop and called a main Keyword Test (without loop). I have hoped - maybe each new calls Keyword Test could find the proper path to object by saved mapping (with pseudo-class):

      .class11.class12:not(.class13) > .class21

       

      Unlikely, without success.

      And then, I found method RefreshMappingInfo. Now, it still works properly. It's amazing.

      Of course, before call child object (in the loop) I call RefreshMappingInfo method on parent object.

      I hope, it will be stable resolving. If not, I come back here.

       

      Really thanks for all of you.

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Great to hear that the problem is solved.

        Actually, .RefreshMappingInfo() method is mentioned in the documentation article that you referenced in your initial message 😉

        Just as a side note: TestComplete provides a really good, correct and descriptive documentation that definitely worth detailed reading.