Python makes a distinction between numbers and strings, so if you have a number as a string (e.g., "562"), and want to access the value as a number, you must explicitly convert it.
Normally this is easily done using the standard Python syntax i = int(s)
where s
is a string and i
is the number it represents. But if you do this in a Squish test script it won't work. Instead you'll get an error message like this:
Unfortunately, Squish defines its own int()
(and type()
) function, so the standard Python versions of these functions are not directly available.
It is, of course, possible to access the original standard Python functions by accessing them via the __builtin__
module. This involves explicitly importing the __builtin__
module as follows:
In Python 3 this module was renamed to builtins
, meaning the import would look like this:
Now the rest of the script can use Python's standard int()
(and type()
) functions by using their fully-qualified names. For example:
See also Squish Python Notes .