Robot Framework : Test two server in same test cases - robotframework

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

Related

Roboframework set variable for RCC command line

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

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

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.

Robot Framework - Using Pabot when customized Java jars are present

Am new to RobotFrameWork.
I have created customized keywords Using Java and created a Jar and
I have executed the test case as follows:
Case1:
Customized Created Jar Name : X.jar
Test Case Name : test.txt
I have successfully executed the test case by the following ways:
Method 1(Using standalone robot framework jar): java -cp X.jar:robotframework-2.5.3.jar org.robotframework.RobotFramework test.txt
Method 2(Using Jython) : jython -P X.jar test.txt
Can any one guide me how to use Pabot in above case.
Case2:
Customized Created Jar Name : X.jar
Test Cases Folder Name : TestCases
Test case folder contents : Test1.txt,Test2.txt,Test3.txt,Test4.txt,Test5.txt
If any of the test cases are not using X.jar
I successfully executed using Pabot command as follows.
Method 1(Using pabot directory Name): pabot TestCases
But as part of requirement in all the test cases we have to use keywords Present in X.jar.In this case how to
use Pabot to execute the test cases.
Can any one guide me in solving these issues
I have tried pabot as follows:
command: pabot --command java -jar robotframework-2.5.3.jar --end-command sx;
Note:sx is the folder name containing test cases.
But am facing an error as follows:
It started execution and am getting error as follows:
File "/usr/local/lib/python2.7/dist-packages/pabot/result_merger.py", line 116, in merge
assert len(result_files) > 0
AssertionError
robotframework-2.5.3.jar is a very very old version (released in Aug 31, 2010) and will most likely not be supported (first pabot was released in Jan 20, 2014). Please find a fresher version of Robot Framework from:
http://search.maven.org/#search%7Cga%7C1%7Ca%3Arobotframework

Resources