I have a rebot command usage which otherwise works fine for following;
rebot --reporttitle "Test Report" --outputdir /logs --output output.xml --report report.html /logs/api.xml /logs/ff.xml /logs/chrome.xml
But one of the test suites doesn't have the api tests hence there is no api.xml getting generated. For this rebot commands doesn't generated the output.xml. Is there a way to pass the xml files as optionals or not necessary to be checked by rebot?
No, there is not. You need to put that logic in a script that calls rebot. Though, if all of your logs (and only your logs) are written to /logs, you can use /logs/*.xml on the command line and it will process all of the .xml files in that directory.
Related
I am trying to save the logs with the particular name in robot framework but not able to do that . Do we have a way to save the log name with the name as we want? If yes then how to do that ?
You have the following options to configure your output files:
-d, --outputdir <dir> Defines where to create output files.
-o, --output <file> Sets the path to the generated output file.
-l, --log <file Sets the path to the generated log file.
-r, --report <file> Sets the path to the generated report file.
So to change the name of the log file launch your tests like this:
robot --log logxyz --report abcreport my_robot.robot
You can check all command line options in Robot Framework User Guide to learn more.
With -T, --timestampoutputs you can add a timestamp to the name of the output files as well. An example name with --log and --timestampoutputs: my_log_file_name-20190103-102712.html.
There are some commands that has to be executed with spec file. Is there any possibility to include commands in spec file.
I have to execute the following statement:
rm -rf build dist
I need to include in spec file.
When I run
pyinstaller --clean abc.spec
it has to delete build folder and dist folder
From the pyinstaller documentation:
The spec file tells PyInstaller how to process your script. It encodes the script names and most of the options you give to the pyinstaller command. The spec file is actually executable Python code. PyInstaller builds the app by executing the contents of the spec file.
So, you can include python code in the spec file to perform the operations you want. But it will need to be python code, not terminal commands as you have.
I am getting the below error while generating report through command line report generation tool.
Exception in thread "main" ru.yandex.qatools.allure.data.ReportGenerationExcepti on: Could not find any allure results at ru.yandex.qatools.allure.data.AllureReportGenerator.generate(AllureRe portGenerator.java:58) at ru.yandex.qatools.allure.data.AllureReportGenerator.generate(AllureRe portGenerator.java:53) at ru.yandex.qatools.allure.AllureMain.main(AllureMain.java:48)
You should provide the Allure results directory to commandline to generate the report, an example:
$ allure generate allure-results -o allure-report
Allure results directory is the directory which contains *-testsuite.xml files. Make sure your C:\TestResults\file.xml/ directory contains at least one such file.
I am using Robot Framework, to run 50 Testcases. Everytime its creating following three files as expected:
c:\users\<user>\appdata\local\output.xml
c:\users\<user>\appdata\local\log.html
c:\users\<user>\appdata\local\report.html
But when I run same robot file, these files will be removed and New log files will be created.
I want to keep all previous run logs to refer in future. Log files should be saved in a folder with a time-stamp value in that.
NOTE: I am running robot file from command prompt (pybot test.robot). NOT from RIDE.
Could any one guide me on this?
Using the built-in features of robot
The robot framework user guide has a section titled Timestamping output files which describes how to do this.
From the documentation:
All output files listed in this section can be automatically timestamped with the option --timestampoutputs (-T). When this option is used, a timestamp in the format YYYYMMDD-hhmmss is placed between the extension and the base name of each file. The example below would, for example, create such output files as output-20080604-163225.xml and mylog-20080604-163225.html:
robot --timestampoutputs --log mylog.html --report NONE tests.robot
To specify a folder, this too is documented in the user guide, in the section Output Directory, under Different Output Files:
...The default output directory is the directory where the execution is started from, but it can be altered with the --outputdir (-d) option. The path set with this option is, again, relative to the execution directory, but can naturally be given also as an absolute path...
Using a helper script
You can write a script (in python, bash, powershell, etc) that performs two duties:
launches pybot with all the options you wan
renames the output files
You then just use this helper script instead of calling pybot directly.
I'm having trouble working out how to create a timestamped directory at the end of the execution. This is my script it timestamps the files, but I don't really want that, just the default file names inside a timestamped directory after each execution?
CALL "C:\Python27\Scripts\robot.bat" --variable BROWSER:IE --outputdir C:\robot\ --timestampoutputs --name "Robot Execution" Tests\test1.robot
You may use the directory creation for output files using the timestamp, like I explain in RIDE FAQ
This would be in your case:
-d ./%date:~-4,4%%date:~-10,2%%date:~-7,2%
User can update the default output folder of the robot framework in the pycharm IDE by updating the value for the key "OutputDir" in the Settings.py file present in the folder mentioned below.
..ProjectDirectory\venv\Lib\site-packages\robot\conf\settings.py
Update the 'outputdir' key value in the cli_opts dictionary to "str(os.getcwd()) + "//Results//Report" + datetime.datetime.now().strftime("%d%b%Y_%H%M%S")" of class _BaseSettings(object):
_cli_opts = {
# Update the abspath('.') to the required folder path.
# 'OutputDir' : ('outputdir', abspath('.')),
'OutputDir' : ('outputdir', str(os.getcwd()) + "//Results//Report_" + datetime.datetime.now().strftime("%d%b%Y_%H%M%S") + "//"),
'Report' : ('report', 'report.html'),
I know that it's not possible to add or remove sections in a Report for Robot Framework, but I wonder if it's possible to change the name of the Report from the Command Line.
So the reason for this is I have two Projects and they have the following folder structure
Project A
Testsuites
Keywords
Variables
And I have the exact same Structure for Project B. Project A and Project B are in the same directory.
When I run multiple tests the Log/Report that appears becomes "Testsuites" Test Log, since that's the name of the Folder where it is.
I want to be able to change the name on the command line so on the log it becomes "Project A Test Log" or "Project B" Test log. Would it be something like this?
pybot ./testsuites AS Project A
There are two ways:
You can give names of output files as pybot parameters:
pybot ./testsuites -o A.xml -l A.log -r A.html -x A.xunit.xml
It might be more convinient to save all files in their own directories:
pybot ./testsuites -d A_files
I think that you could mark tests from different projects with different tags and than you could run different tests
pybot -i projectA -l projectA_log.html -r projectA_report.html ./testssuites
or
pybot -i projectA -d projectA ./testssuites
pybot has a --name option. From the user guide:
-N, --name
Sets the name of the top-level test suite.
For slightly more information see http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#setting-the-name