Forum Discussion

ray_mosley's avatar
ray_mosley
Frequent Contributor
7 years ago

COnverting from VBScript to python

We are converting our framework from VBScript to python on Windows, and I am having trouble finding objects and modules.

 

My Project Script directory contains:

 

Script

    Drivers folder

         QASSL_Library (Class modules and common procedures, including test driver)

    Smoke

          smoke test suite file .py

    Billing

          ....

 

I am trying without success to use sys.path.append to add paths to the Script\Drivers folder and the Scripts\Smoke folder. Nothing changes - the DOS path/Path/PATH variable is still the same.

 

QUESTION 1: Do I need to set any of the python env variables like PYTHONPATH when using the TestComplete python IDE and execution?

 

QUESTION 2: How do I use sys.path.append for so that the .py tests can correctly import given my folder structure?

 

Thanks.

 

 

  • baxatob's avatar
    baxatob
    Community Hero

    If Script\Drivers are only items of your TestComplete project structure (and not the objects of your file system), you should not add it to the system path.

  • What version of TestComplete and what version of Python are you using?

    • ray_mosley's avatar
      ray_mosley
      Frequent Contributor

      I am using TestComplete 12.20 which has python 3.4.

       

      As a newbie to python, but a veteran of many other languages, I assumed that there was a problem in python FINDING my modules because of the folder structure I described (below).

       

      If I put all my modules in Project.Path plus Script, python finds and executes the modules (I think; that's what I am about to try), but we would like to group tests using the folder structure.

       

      Perhaps my assumption that I need to append my folders to PATH, but I have found nothing that lets me execute from that structure.

       

      My Project Script directory contains:

       

      Script

          Drivers folder

               QASSL_Library (Class modules and common procedures, including test driver)

          Smoke

                smoke test suite file .py

          Billing

  • NisHera's avatar
    NisHera
    Valued Contributor

    Your question is not that clear to me ...

     

    But if your problem is referring one unit from other (say one script from the other) 

    you have to refer this and this

     

    if you need to refer external python libraries (like request, json etc..)

    you have to physically place those in <TestComplete>\Bin\Extensions\Python\Python36\Lib folder 

    and use "import command"  for more please refer this

     

     

    QUESTION 1: Do I need to set any of the python env variables like PYTHONPATH when using the TestComplete python IDE and execution?

    Answer:  No TC use python installation in your <TestComplete>\Bin\Extensions\Python folder even though you have other python installation in your machine.

     

    QUESTION 2: How do I use sys.path.append for so that the .py tests can correctly import given my folder structure?

    Answer: as far as I know you can not. you have to place those files in TC define folders...please refer my first comment.