Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Why do I encounter the error “SilkTest.Ntf.InvalidObjectHandleException: The object for this handle has been invalidated”?

Why do I encounter the error “SilkTest.Ntf.InvalidObjectHandleException: The object for this handle has been invalidated”?

During replay of a script if you encounter the above error then this is an indication that the handle to the current screen within the “Application under Test” has been invalidated.  The reason why the handle has become invalidated is because each time a new screen within the application is generated a new handle is created.

Consider the example below, the error was returned when pressing the “Next” button within the “Install Shield” window.

 

As you can see, when you press "Next", although the screen is within the same application in reality they are different objects with their own handles.

 

 

This causes a problem in Silk4Net because the “Open Agent” used Dynamic Object Recognition; in that a locator contained within a declaration is computed when it is first used, later usage of the same declaration assumes that it is still the same runtime object. 

Thus, when the Next button is clicked in Install Shield, the top level window is recreated and given a new handle. When this occurs the original variable reference "qARunSetup" becomes invalid.

[TestMethod]
public void TestMethod5()
{
    Dialog qARunSetup = _desktop.Dialog("QARun Setup Dialog");
    qARunSetup.SetActive();
    qARunSetup.PushButton("Next").Select();
    qARunSetup.PushButton("Yes").Select();
}

To work around the issue, you can force the Open Agent to re-find the object by specifying the X-Path locator, like so:

[TestMethod]
public void TestMethod5()
{
  _desktop.PushButton("//PushButton[@caption'Next']").Select()           _desktop.PushButton("//PushButton[@caption'Yes']").Select() 

}

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2014-03-12 16:36
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.