Object invoked disconnect from client at website deployment
Hi,
I need to run smoke test at the deployment of our website. The test works, except at the deployment. I always get an error native.
Error: The object invoked has disconnected from its clients.
at Error (native)
This error occurs at every deployment. I rerun the same test right after the failure and it pass.
Might it be something from our website that cause this or a bug in TestComplete?
I am using TC12.10.602.7 - Our website is in asp.NET
--EDIT--
Here the code I use
function getAllPages()
{
var arrPages = Sys.Browser('chrome').FindAllChildren("ObjectType", "Page", 1).toArray();
return arrPages;
}
function getCurrentPage()
{
var objCurrentPage = null;
var arrPages = getAllPages();
var stopTime = GetTickCount() + 30000;
while (objCurrentPage === null && arrPages.length > 0)
{
if (GetTickCount() >= stopTime)
{
Log.Warning("Timeout Reached, unable to get the current page");
break;
}
for (indPage in arrPages)
{
var objPage = arrPages[indPage];
if ( objPage.Enabled && objPage.Visible )
{
objCurrentPage = objPage;
break;
}
}
}
return objCurrentPage;
}
function tryGetElementByCSS(cssSelector)
{
var elemFound = null;
var fromElement = null;
var wait_timeout = 10000;
var max_wait_timeout = GetTickCount() + wait_timeout;
do
{
if ( (wait_timeout > 0) && (GetTickCount() > max_wait_timeout) )
{
var strExtraInfo = "CSS Selector:" + cssSelector;
Log.Warning(" TIMEOUT:'" + wait_timeout + "' milliseconds reached when trying to get element", strExtraInfo);
break;
}
fromElement = getCurrentPage().contentDocument;
elemFound = fromElement.querySelector(cssSelector);
}
while (elemFound == null)
return elemFound;
}
function test()
{
Sys.Browser('chrome').ToUrl('...');
var tableObj = tryGetElementByCSS('div.page section.list');
return (tableObj != null);
}
With my code, the page should wait at least 30sec before returning false, but i got the error after 6-12 sec of execution.
I fix my problem,
I was getting a problem cause the time i was getting the document object and the time i was doing a query selector. The page was refreshing (due to the first load) and then my object got disconnected when trying to do the querySelector.
Basicly i did :
try { fromElement = getCurrentPage().contentDocument; elemFound = fromElement.querySelector(cssSelector); } catch (ex) { fromElement = null; elemFound = null; }
So if the problem occur i just continue my loop and return null if I don't get what i want ater the timeout (for my case, it's doing what i want).