Detail NameError: name 'test' is not defined when executing Squish Web test case using the Squish IDE
-
I am new to Squish and its architecture.
Whenever I execute a test, I get Script error that refers to a test class name not found.
More specifically:
def addMessageToLog(self, message):
test.log(message)test is not found.
Test Environment:
Squish IDE 8.0.0
Build Id: 202406191427
Python Version being used in from the Squish install folder Squish\python3\python.exe
Windows 10 Enterprise 21H2
PYTHONPATH contains the project directory that I am creating tests in.
System Path contains the Squish python3 folder and Scripts folder.Not sure why it cannot find this?
Thank you .
-
Hi Mike,
I guess you are defining this function in a python module other thantest.py
. In general you have at least to ways to include such module in your test:- source it - https://doc.qt.io/squish/source-function.html#source-function
- use native python imports
The first approach lets you use your function as it is. However, in most of the cases I recommend using native python import, even though it may require some extra work from you. Your custom Python modules won't have any knowledge of the Squish API until you import the required modules—like the
test
module you mentioned.import test def addMessageToLog(self, message): test.log(message)
You can learn more about it in the https://qatools.knowledgebase.qt.io/squish/howto/using-squish-functions-python-modules-packages/ knowledge base article.