TG3017
TG3017

Reputation: 33

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

Upvotes: 1

Views: 4093

Answers (3)

playlistaccount
playlistaccount

Reputation: 53

Setting default python version to 3.6 worked for me

Upvotes: 0

forkdbloke
forkdbloke

Reputation: 1565

The reason you are getting the below error is , you need to go to the same virtualenv/interpreter where you have installed robotframework,as you have configured your eclipse to run on. Otherwise, you will get the below error.

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

Steps to remedy

  1. You need to use the same virtualenv/interpreter and
  2. then make sure you have robotframework installed and
  3. then you need to invoke robot, only then it is going to work.

APPROACH#0

Assuming that you have created a virtualenv/interpreter with robotframework installed successfully, then you need to just

  1. cd to that specific directory and
  2. then execute robot as mentioned below.

If you want to run all the testcases from all the files and folders under Prepod

cd /Users/tanyagrover/Desktop/Robot\ Files/Charcoal\ PreProd
robot *.robot

NOTE: few users are confused regarding "cd" when dir name contains space i have created a simple folder name "sample sd"(there is a space in the folder name)

On mac this works,

cd sample\ sd/
06:30 PM##~/sample sd::>

Upvotes: 2

asprtrmp
asprtrmp

Reputation: 1062

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'.

Upvotes: 1

Related Questions