The functions provided by Squish can be replaced. (The original functions can still be used if the replacement is done correctly.)
This can be a convenient way to modify the behavior of the commands that Squish records, without having to modify the recorded script code.
Functions can only be replaced after the AUT has started¶
When replacing Squish script functions it is important to do this after the application has been started by Squish. (This is because Squish creates some of its functions after the AUT has started, so these are not available to be replaced until that point.)
A typical test case script that replaced some Squish functions would look like this:
function is discussed below.)
source() call is used to execute another script inside this one. The other script can create variables, functions, classes, and so on, that can then be used as if they had been created in the current test case. The advantage of having all this in a separate script is that the script can then easily be used by multiple test cases.
For example, the statement...
...loads the file
squish_func_replace.py which contains the replacement functions and their "registration".
Here is an example of such a file which shows how to replace Squish's
mouseClick() function with a customized version:
Note that the original
mouseClick() function can still be accessed like this: