How can i run robot test cases without ride using test suite - robotframework

I am new to robot framework and wanted to see if i can run test cases without RIDE. I want to create test suite and run test cases sequentially without using RIDE. I went through documentation but could not understand it.
Ex: Test Suite
Test Case 1
Test Case 2
Test Case 3
i would like to put my references to all my resource files to test suite and run all test cases. I can do this using RIDE but wanted to know if i can do this without using it. Do i need to create batch file to do this or any other method to run? Any example will help me. Thank you for advance.

When you install robot, you also installed a program called robot (or pybot in older versions), which is the official robot test runner.
If you have a test suite named "my_tests.robot", you can open up a command prompt (bash on *nix, powershell or command.exe on windows) and type the following command (assuming that robot is in your PATH environment variable, which it probably is):
$ robot my_tests.robot
If you have a collection of suites in a folder, you can give pybot the name of the folder rather than the name of a test file.
To see a list of all robot command line options, use the --help option:
$ robot --help
For more information see Starting test execution in the robot framework users guide.

if you use sublime-text/bracket/Atom/Emacs/vim ... you also have some plug-in :
http://robotframework.org/#tools

Show the path of test suite
exmp: Location of my 'catiav6' test script_
cd C:\Users....\Desktop\catiav6
Run following command from cmd
For single test case:
pybot --test 'Name_of_single_test_case' 'Name_of_test_suite'
For all test cases:
pybot --test * 'Name_of_test_suite'

Related

Can Robot Framework test suites be called with command-line parameters?

We are developing / publishing robot-tests in a git environment, where the public (published) git has slightly different settings then the development git (due to personal work-space (development) vs global environment settings).
Because of this one of our robot keywords is different for development and public.
Currently we manage this by commenting out 1 line in the keyword's .robot implementation for the development git and another one for the public git, but this is error prone.
Is it possible to call pybot with some extra command-line options which will be passed on via the .robot files to the python files implementing the final keywords so we can move the 2 lines from the .robot file to the python implementation and decide which to use based on the given command-line option?
Check the Setting variables in command line part of the user guide. With the --variable MYVAR:value command line argument you can create global variables.
For example:
*** Variables ***
${VAR} localenv # this is not necessarily needed, it is used to set default value
*** Test Case ***
Test
IF '${VAR}' == 'localenv'
Log Do this
ELSE IF '${VAR}' == 'globalenv'
Log Do that
END
Run locally
robot test.robot
on global:
robot --variable VAR:globalenv test.robot

Allure report with robotframework is showing html file without the test run results

I am running tests with robot framework and i want to get allure report. I have been able to successfully install it and i can see that the .xml files are getting created with the test run results. But when i do "Allure serve " it displays a report without any test information in it.
Can someone please help me? I am using AllureReportLibrary in the robotframework
share one lession.
robot --listener allure_robotframework CustomerService.robot
Default output directory is output/allure.
allure generate output --clean
where I use this command to generate report, no testcase in report.
allure generate output/allure --clean
when I change to this dir, it works. So I guess the innermost directory is necessary.

How to see logs of running robot script?

The robot scripts when ran on RIDE, generate output.xml, report.html etc files, once run is over.
Is there any way available to view logs when script is still running? (When I use pause on failure)
Also some times I had to Stop/Abort the run in middle, and no logs are generated in such cases.
Kindly help,
Thanks in advance
As for first part — RIDE runs tests adding own listener, providing more verboseness of the output and pausing/resuming functionality.The easiest thing is to run tests not from RIDE, but from console using robot/pybot script. In this case much less logs are written to output (though it doesn't provide pause/resume functionality).
For second part — robot (RIDE starts robot script — you can see it in execution log: command: pybot.bat...) generates output.xml file not after but during execution, so generated output.xml is not valid until test is finished. After normal execution rebot tool generating log.html automatically. So generally it's possible to take following steps:
"Fix" your incomplete output.xml file after execution stop with fixml. output.xml location for RIDE execution can be found in the very same execution log of yours (e.g. ...\appdata\local\temp\RIDEv_0yrp.d\ in my case)
Run rebot stand-alone: rebot output.xml --log log.html --report report.html. Rebot options description you can check using rebot --help (as usual)
Please also note that directory where RIDE output files are stored is temporary — exists only when RIDE is started. You will lose your output on exiting RIDE
I'm using RIDE 1.5 so maybe my answer is not valid for other versions
In RIDE, under Run Tab , when you are running the scripts , you have a option, show message log, it will shows the runtime log.
Try this out.

How to pass variable file to a test when running robot framework tests on sauce labs?

I am trying to run some robot framework tests on sauce labs. I am not able to pass a variable file to my pybot command.
When I run my tests locally I use this command :
pybot -vbrowser:firefox -vbaseur --variablefile ../VariableFiles/superdesk.py mytest.robot
On sauce labs I need to pass some other variables: sauce username, key...
pybot -v browser:firefox -v baseurl:http://myurl.fr -v sauce_apikey:mykey -v sauce_platform:linux -v sauce_username:myusername mytest.robot
How could I pass a variable to the second command as as soon as I pass --variable filemy tests run locally and not on sauce labs.
I have tried this command
pybot -v browser:firefox -v baseurl:http://myurl.fr -v sauce_apikey:mykey -v sauce_platform:linux -v sauce_username:myusername --variablefile myvarfile.py mytest.robot
When running the command above the variable file is not taken into account. My tests run with default variables
The literal answer to your question is "you pass a variable file to a test the same way no matter whether you are using saucelabs or not".
Unless robot is throwing an error, your variable file is being passed to robot when you include --variablefile myvarfile.py. You can write a simple test to verify that, by having the test log the values from the variable file.
If you are seeing different behaviours, the behaviours must be in your test cases, or in your own variable file. There is no feature in robot that behaves differently when running on saucelabs or not.

How do you run tests in parallel using robot framework? Issues with Parallel Library

The below is the code present in parallel_tests.txt
*** Settings ***
Library Parallel
*** Test Cases ***
Runner
Run Parallel Tests Hello World
Hello
[Tags] parallel
Log Hello123
World
[Tags] parallel
Log World123
I am trying to execute this test case file
from terminal using jybot as below:
jybot parallel_tests.txt;
I am getting the following error:
No keyword with name 'Run Parallel Tests' found.
How to execute both test cases Hello and World ,in parallel in robot framework using parallel library.
Slightly different use case but have you tried using pabot?
I haven't gone down the rabbit hole with this one so don't have an in-depth understanding but I do use it for cross-browser tests via sauceLabs. It will work differently from how you want in that it does parallel runs but by test suite rather than test case level. Perhaps this is configurable? Unfortunately as mentioned I just know enough to get it working for my needs and haven't done a deep dive.
Any questions let me know and I'll try to help.
Here's a quick example as requested, I've stripped lots of our stuff which is useless in your case but left some in so you can see how to build up. I changed the processes parameter from %processes% to 2, the end result is the same, in my case these values are coming from a teamcity build configuration:
pabot --processes 2 --variable environment:%environment% --name OS_X_10.9-Firefox --variable browser:%browser% --listener robot-tc-listener --include %includetags% --exclude %exclusiontags% --outputdir %PabotResults_DIR% --output output.xml --report report.html --log log.html tests
Which version of RobotFramework are you using? The Parallel library was removed in 2.5 (see this ticket, though there may be distant plans of reintroducing it).
I tried to reproduce your issue using this file with RF version 2.8, but there are several compatibility problems, as expected.
Are you sure that the library has been loaded properly? When it fails, in addition to the error, you will also get a message telling you that the keywords are unavailable.

Resources