Roboframework set variable for RCC command line - robotframework

The documentation indicates we should be able to change Scalar variables in .robot files when we execute a robot with the command line https://robocorp.com/docs/languages-and-frameworks/robot-framework/variables with the option --variable https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#setting-variables-in-command-line
But every attempt like this rcc run --variable MYVARIABLE:value result with this error Error: [rcc v11.4.3] unknown flag: --variable
How can we define différents variables each time we wan't to execute the robot ?

Looks like variables for RCC have been disabled/removed or not implemented.
The answer --> https://forum.robocorp.com/t/how-to-pass-variables-when-running-rcc/1209
On linux, environment variables have to be used, for example: MYVARIABLE="123" rcc run

Related

How to Mark final result as PASS if one of the Test Suite in Robot Framework Passes?

We have a scenario where we need to run the same test suite on 2 different Geo Redundant servers to check the health. If any one of them passes the final Report & Log should show the suite as pass.
Is there a way in the robot framework to achieve this?
For example, lets say I have following robot file:
Health_Check_Server.robot
*** Test Cases ***
Validate Server
[Arguments] ${Server_credentials}
Login to Server ${Server_credentials}
${HC_Output}= Run Command ${health_check command}
$HC_Status}= Validate Output ${HC_Output}
I want to execute it like:
robot --variable Server_credentials:<ServerA details> Health_Check_Server.robot
robot --variable Server_credentials:<ServerB details> Health_Check_Server.robot
Is there any option in the rebot command using which I can OR the results?
Meaning if any of these Servers are in healthy state, the final results should show PASS. Only if both of the suites failed, the final result should be marked as FAIL.
Thanks in Advance!
Just save each result in separate file, and than merge the result using rebot.
The log will have the test inside as passed, you should see a note if one of the tests was failed.
robot --variable Server_credentials:<ServerA details> --output server_a.xml Health_Check_Server.robot
robot --variable Server_credentials:<ServerB details> --output server_b.xml Health_Check_Server.robot
rebot --merge server_a.xml server_b.xml

Robot Framework : Test two server in same test cases

I have created files
valuset.dat:
[Server1]
tags=x.x.x.x
HOST=x.x.x.x
USERNAME=hsiaoi
PASSWORD=yse980327
[Server2]
tags=y.y.y.y
HOST=y.y.y.y
USERNAME=bu11admin
PASSWORD=bu11
and Test suite.dat
When I executepabot --pabotlib --resourcefile .\valueset.dat '.\Test suite.robot'
Only the first server1 will be tested.
What should I do if I want to test two servers at the same time?
It seems there're two options:
You create the same test suite twice and later run your suites like $ pabot --pabotlib --resourcefile valuset.dat tests. This way, one test suite will pick up values under [Server1], and the other values under [Server2]. The disadvantage is you duplicate code.
You can define multiple argument files on the command line like so: $ pabot --pabotlib --argumentfile1 arg1.txt --argumentfile2 arg2.txt tests. So you need to create these two argument file:
arg1.txt:
--variable tags:x.x.x.x
--variable HOST:x.x.x.x
--variable USERNAME:hsiaoi
--variable PASSWORD:yse980327
arg2.txt:
--variable tags:y.y.y.y
--variable HOST:y.y.y.y
--variable USERNAME:bu11admin
--variable PASSWORD:bu11
This approach has the advantage that you don't duplicate any code, you have just one test suite and two argument (configuration) files.
You can fine more in this stackoverflow thread: robot framework with pabot : is it possible to pass two different values to a variable in two tests and in the README file of pabot: https://github.com/mkorpela/pabot/blob/master/README.md

Unable to run shell script from test case

I'm trying to invoke a shell scrip from within a .robot test case.
The .sh file is in the same folder as the .robot file
*** Settings ***
Library Process
*** Test cases ***
Run the shell script
Start Process ./getIDfromDB.sh shell=yes
I'm getting the error:
Setting variable 'Start Process ./getIDfromDB.sh' failed: Invalid variable name 'Start Process ./getIDfromDB.sh'.
Running on Ubuntu
Researched documentation for Robot framework but could not find a solution. Maybe digging in the wrong spot.
I'm not sure how you are trying to set the path of the shell script in the robot file. The error message seems to convey that something is wrong with the way you're initialising the variable to hold the path.
The following code should work:
*** Settings ***
Library Process
*** Variables ***
${pathToScript} ./getIDfromDB.sh
*** Test cases ***
Run shell script
${output} Run process ${pathToScript} shell=yes
The return code and the output displayed in the terminal are stored in the ${output} variable. You can access the details as ${output.rc} and ${output.stdout} respectively.
You can find more details about the result object here.
According error details the keyword is not recognized, I think, you need add extra spaces after keyword name:
Start Process ./getIDfromDB.sh shell=yes

Error when passing command line arguments in robot framework

I am trying this to pass the argument through command line
robot testingxpath.robot --variable EXAMPLE:value
[ ERROR ] Parsing '--variable' failed: Data source does not exist.
Try --help for usage information.
Not sure what is wrong. Any help is appreciated.
Try robot --variable EXAMPLE:value testingxpath.robot
User guide (ch. 3.1.2) says:
When options are used, they must always be given between the runner
script and the data sources.

How can I get Interim report when test failed and I wish to continue test in Robot Framework

I use robot framework at following environment.
Python 2.7.6
robotframework 2.8.7
Ubuntu 14.04.3 LTS
I make directory like followings,
and execute robot like this to get report in TestPTX units.
TestCaseRoot
L TestPT1
L test_1.robot
L test_2.robot
L test_3.robot
L TestPT2
L test_a.robot
L test_b.robot
$ pybot -L TRACE -b debug.log --outputdir <LOG_DIR> TestPT1/
In this case, test_1,test_2,test_3 are executed and report and log file is included one file.
But when test_2 were failed , pybot continue to execute test_3, and until test_3 were done report were not outputed.
I wish that if test_2 were failed , output report.html and log.html of test_1 and test_2(Interim report), and pybot continue to execute test_3.
Is any idea of grant my wish?
You cannot get what you want. Robot keeps the report in memory and only writes it to disk when the entire test run is completed.
You can create a listener that will give you the same information that is in the report if you wish, and you can use that to write your own file. Or, you can create a custom script that runs each suite separately, and then combines all of the individual reports after all of the tests have run.

Resources