Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. QA Tools
  3. Squish
  4. Detail NameError: name 'test' is not defined when executing Squish Web test case using the Squish IDE

Detail NameError: name 'test' is not defined when executing Squish Web test case using the Squish IDE

Scheduled Pinned Locked Moved Unsolved Squish
2 Posts 2 Posters 395 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mikeWat
    wrote on last edited by
    #1

    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 .

    1 Reply Last reply
    0
    • JakubTopolskiJ Offline
      JakubTopolskiJ Offline
      JakubTopolski
      wrote on last edited by JakubTopolski
      #2

      Hi Mike,
      I guess you are defining this function in a python module other than test.py. In general you have at least to ways to include such module in your test:

      1. source it - https://doc.qt.io/squish/source-function.html#source-function
      2. 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.

      ⚙ Test Automation Consultant 🐸 Squish Expert 🐍 Python Enthusiast
      https://cyberalpaca.com
      https://www.linkedin.com/in/jakub-top/

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved