The simplest and most obvious way to close a window by SilkTest is using Close() method. However, sometimes this method doesn't work. For example, try to open Notepad, write some text there and then execute the following code

[ ] Notepad.SetActive ()
[ ] Notepad.Close ()

Notepad will show a message box about changes made and will wait for user's actions, and SilkTest will post an error message to the log

*** Error: Window cannot be closed

Of course, such situations should be foreseen and processed in scripts, but what if we need to close a window anyway? In this case we can use Kill() method which simply kills a window. For some reason this method is not described in SilkTest help, but it can be found in the winclass.inc file.

[ ] Notepad.SetActive ()
[ ] Notepad.Kill ()

You must be logged in to post comments