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() }
↧