"No matching ... overload found Following overloads are available"

Last edited on

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:

No matching 'int(str)' overload found: Following overloads are available:
 int::int(int *)

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:

import __builtin__

In Python 3 this module was renamed to builtins, meaning the import would look like this:

import builtins

Now the rest of the script can use Python's standard int() (and type()) functions by using their fully-qualified names. For example:

# Python3
s = "562"
i = builtins.int(s) # i is an int of value 562

# Python2
s = "562"
i = __builtin__.int(s) # i is an int of value 562

See also https://doc.froglogic.com/squish/latest/all/rgs-py.html .