Ask a Question

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

SOLVED
RUDOLF_BOTHMA
Community Hero

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


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
6 REPLIES 6
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/refres... 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;

?

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
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).  


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

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  Smiley Tongue 

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,

 


-------------------------------------------------
Standard syntax disclaimers apply
Regards,


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

 


-------------------------------------------------
Standard syntax disclaimers apply
Regards,

> At some point IE just starts a new process 

Yes, I've also have met this on some environments.

It looked like that IE process was hanging somewhere on close (though this could be due to the tested web application) and any attempt to address it from TestComplete (like browser.Exists, etc.) caused its crash or TestComplete problems. As the chances for the problem to be investigated by developers were extremely low (the problem could not be reproduced manually), we ended up with the approach to .Terminate() the browser process if tests were executed against IE browser.

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================


@RUDOLF_BOTHMA wrote:

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

 Yes, it looks reliable combined with browser wait.  I don't want to use RefreshMappingInfo if I can help it.  This script gets called on virtually every KWT, so refreshmappinginfo() would push the test time up by a huge amount.  There are places where NameMapping is extremely useful because sometimes identification is a mess and naming too, but I may have to work this into the mix to avoid the caching issues I have experienced previously and had to work around by refreshing.  Could end up with nice performance at the cost of code readability.  Some object names just don't tell you anything about what you are working with Smiley Surprised  

 


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
cancel
Showing results for 
Search instead for 
Did you mean: