Search code examples
command-linerobotframework

How can we run Robot Framework files and Test cases using command line?


Test Case Hierarchy

Please can anyone suggest and help how can we execute the Robot Framework Test Cases and Files via command line ?

My Robot Framework Directory Location is as follows : /Users/tanyagrover/Desktop/Robot Files/Charcoal PreProd

I've tried :

robot -L debug Charcoal preprod.robot

and got error as :

  File "/usr/local/bin/robot", line 6, in <module>
    from robot.run import run_cli
ModuleNotFoundError: No module named 'robot'

I'am using ride.py to create my test cases and the test cases are running fine when i'm using RIDE UI. But I want to run my test cases using Robot CLI. Whenever I'am executing my .robot file using robot command I'am getting following error

robot Login.robot Traceback (most recent call last): File "/usr/local/bin/robot", line 6, in from robot.run import run_cli ModuleNotFoundError: No module named 'robot'

Thank You


Solution

  • First, make sure you have robot framework installed and it is found in PYTHONPATH environment variable.

    For executing the tests, there are many ways to do this.

    Option #1: Go to Charcoal PreProd folder and just robot Suites

    Option #2: Go to Suites folder and just robot .

    Option #3: If you wanna run only Login test suite, in Charcoal PreProd folder: robot Login.robot (assuming the file extension for Login file is robot).

    Also note that the last argument cannot have spaces as you have in Charcoal preprod.robot. In this case, you should use quotes: 'Charcoal preprod.robot'.