How to pass command line arguments in robot framework script

219 views
Skip to first unread message

Srinivasan Shanmugam

unread,
Nov 13, 2018, 11:33:59 PM11/13/18
to robotframework-users
Dear Robot Framework Experts,

As am newbie to robot framework

Could you please help, Is there any possibility of passing the command line arguments to the robot frame work script, while running it?

Thanks in advance

Tatu Aalto

unread,
Nov 14, 2018, 1:48:18 AM11/14/18
to srinivasan, robotframework-users
Ugh

From command line, it's not possible during the test execution. But it sounds like a you are having a problem, which you want to solve. Could you describe the problem and what is your goal you want to reach and perhaps we are able to guide you to alternative solutions. 

-Tatu 

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

srinivasan

unread,
Nov 14, 2018, 1:50:48 AM11/14/18
to Tatu Aalto, robotframework-users
Sure, I will do that. 

Anne kootstra

unread,
Nov 14, 2018, 2:48:16 AM11/14/18
to robotframework-users
As highlighted by Tatu, if you provide some more details perhaps we can help you better. 

However, if you want bring in information from the command line and use it in your test case, then you should have a closer look at the Robot Framework guide section Setting variables in command line. More generic command line arguments can be found in the Guide in the aptly named section: All command line options. The same information can be seen when executing:

robot -h

Kind regards,

Anne

Op woensdag 14 november 2018 05:33:59 UTC+1 schreef Srinivasan Shanmugam:

srinivasan

unread,
Nov 14, 2018, 3:42:11 AM11/14/18
to koot...@gmail.com, robotframework-users
Thanks a lot Anne and Tatu for you prompt replies,


My question is, does the value of the variable "SIGNAL_LEVEL_THRESHOLD" passed from command line override the values defined in the Robot framework code (wifi_testing.robot) (ie., 
${SIGNAL_LEVEL_THRESHOLD}         -90)

How can I add the print for variable "SIGNAL_LEVEL_THRESHOLD" in the wifi_testing.robot, so that I can run  and verify on the console  of the board?


python3 -m robot --variable SIGNAL_LEVEL_THRESHOLD:-60 wifi_testing.robot

Robot framework code (wifi_testing.robot):

*** Variables ***
${SIGNAL_LEVEL_THRESHOLD}         -90


*** Test Cases ***

Check for Wi-Fi Signal Strength with Threshold
     ${link}     ${level}     ${noise} =     Get Wifi Signal Quality
     Should Be True      ${level} >= ${SIGNAL_LEVEL_THRESHOLD}

Many Thanks in advance,
Srini





--

Tatu Aalto

unread,
Nov 14, 2018, 5:23:04 AM11/14/18
to srinivasan, koot...@gmail.com, robotframework-users
Ugh

This is a question about variable priority and scope. That is explained in the user guide: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#variable-priorities-and-scopes

-Tatu 

Sourab Dolai

unread,
Nov 14, 2018, 11:00:25 AM11/14/18
to robotframework-users


Use Keyword 'Set Suite Variable' for local variable
Use Keyword 'Set Global Variable' This is for global scope of variable
Use Keyword 'Log To Console' To check value of variable in Message/commad promt
Log - for Displaying variables in Log Files

You can Declare Variables in resource bot file and use in your main file

Tatu Aalto

unread,
Nov 14, 2018, 1:09:36 PM11/14/18
to sourab...@nividous.com, robotframework-users
Ugh

Test suite is not same local scope, Robot Framework has four (4) different scopes for variables: Global, Test Suite, Test Case and Local scope. Please see the user guide for more details: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#variable-scopes

-Tatu

--

sagar mopagar

unread,
Nov 15, 2018, 6:14:32 AM11/15/18
to aalto...@gmail.com, sourab...@nividous.com, robotframe...@googlegroups.com
Hi,

I am using the below format to send command line arguments:
robot -d results -v Browser:Chrome -N "Front Office Tests" -i Team tests/login.robot

use -v to indicate the start of variables. Then use variable name without $ and Curly braces{}.

This is working for me.

Best Regards,
Sagar

Reply all
Reply to author
Forward
0 new messages