Forum Discussion

RUDOLF_BOTHMA's avatar
RUDOLF_BOTHMA
Community Hero
6 years ago

aqObject.GetPropertyValue object does not exist after an exist check passes

Hi all,

 

New one that suddenly started and intermittently pops up.

 

Code:

 

var loadingPanelObj = Aliases.browser.FindChildEx(["ObjectType","ObjectIdentifier"],["Table","ASPxLoadingPanelMain"],3,true,10000);
if(loadingPanelObj.Exists && aqObject.IsSupported(loadingPanelObj,"VisibleOnScreen"))
{
   //So, Loading Panel exists, but the following line of code errors
var isVisible = aqObject.GetPropertyValue(loadingPanelObj,"VisibleOnScreen");
// The error: The Object "Table("ASPcLoadingPanelMain")" does not exist }

Any thoughts about this ? At this point in the KWT I would expect the object to be on the page, so that's as expected. In theory if the .Exists is true, the next step shouldn't say it doesn't exist ?  If it helps, it seems there may be a pattern that this only appears to happen in the places where this script is the first thing called after a postback, but without navigating to a new URL e.g. clicking the save button and waiting for a redirect to itself

  • Hi,

     

    > In theory if the .Exists is true, the next step shouldn't say it doesn't exist ?

    Correct. But only in case if the object was not recreated (or just destroyed).

    Note, that you are using Aliases to reference test objects and this is fine. But Aliases functionality has some specific that it caches objects once found and tries to reuse them later. And if the object is recreated, the problem will occur. See https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/refreshmappinginfo-method.html for some more description.

     

    My guess is like yours: the target table might be recreated by script code on the page and this invalidates its previously found (and cached) instance. If this is the case, then you need to figure out the way (or ask developers to implement some flag for you) to identify if test code must wait for the table to be recreated.

     

    P.S.

    Out of curiosity: why instead of

    var isVisible = aqObject.GetPropertyValue(loadingPanelObj,"VisibleOnScreen");

    not to use just

    var isVisible = loadingPanelObj.VisibleOnScreen;

    ?

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    > In theory if the .Exists is true, the next step shouldn't say it doesn't exist ?

    Correct. But only in case if the object was not recreated (or just destroyed).

    Note, that you are using Aliases to reference test objects and this is fine. But Aliases functionality has some specific that it caches objects once found and tries to reuse them later. And if the object is recreated, the problem will occur. See https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/refreshmappinginfo-method.html for some more description.

     

    My guess is like yours: the target table might be recreated by script code on the page and this invalidates its previously found (and cached) instance. If this is the case, then you need to figure out the way (or ask developers to implement some flag for you) to identify if test code must wait for the table to be recreated.

     

    P.S.

    Out of curiosity: why instead of

    var isVisible = aqObject.GetPropertyValue(loadingPanelObj,"VisibleOnScreen");

    not to use just

    var isVisible = loadingPanelObj.VisibleOnScreen;

    ?

    • RUDOLF_BOTHMA's avatar
      RUDOLF_BOTHMA
      Community Hero

      Edit: They actual respone to AlexKaras that got lost when my browser crashed:

       

      I'm going to see if I get different results from Sys.browser rather than Aliases...

       


      <

      Out of curiosity: why instead of

      var isVisible = aqObject.GetPropertyValue(loadingPanelObj,"VisibleOnScreen");

      not to use just

      var isVisible = loadingPanelObj.VisibleOnScreen;

      ?


      Because of copy, paste and inexperience when I originally wrote it  :smileytongue: 

      For curiousity, this is the code that follows it.  This panel is AJAXy,  So I need to keep polling to see if it's visible.

       

      var retries = 0;
          while(isVisible && retries < 100)
          {
            retries++;     
            if(retries==2)
              LogMessageVerbose("***** WaitLoadingPanel() had to wait *****"); 
            if(loadingPanelObj.WaitProperty("VisibleOnScreen",false,100))
            {
              LogMessageVerbose("***** WaitLoadingPanel() finished waiting *****"); 
              break;
            }
          }

      I could probably get away without the while loop, but it allowas me to log whether the load panel was visible and how long.

       

      Regards,

       

      • RUDOLF_BOTHMA's avatar
        RUDOLF_BOTHMA
        Community Hero

        I'm going to see if I get different results from Sys.browser rather than Aliases...

         So far so good...

         

        Now to figure out why I end up with mutiple iexplorer.exe processes running (and edge as well) after a while.  At some point IE just starts a new process and I get ambiguous browser.  Thats for a different thread though

         

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    My guess:  If this is right after a post-back, the page load may not be complete yet.  You might need to, before you execute that code, call a browser.page.Wait call to wait for the page load.  The table MAY exist immediately... but when the page refreshes, the "handle" that you found is no longer valid (table destroyed and recreated).