How to generate report.html for every testsuit( .robot file) in RoboTFramework? - selenium

I,m using single pycharm project to run different test files for a particular website.
ex -: I'm having robot files with test cases such as
loginTest.robot , purchasetest.robot , signinwith_facebook.robot
When I run the code for each robot file, the report files are being overridden.
How to generate a separate report file for each .robot file when the test file is running.

Are you using robot command to execute? If yes, you can run with these arguments:
-d --outputdir dir Where to create output files. The default is the
directory where tests are run from and the given path
is considered relative to that unless it is absolute.
-o --output file XML output file. Given path, similarly as paths given
to --log, --report, --xunit, and --debugfile, is
relative to --outputdir unless given as an absolute
path. Other output files are created based on XML
output files after the test execution and XML outputs
can also be further processed with Rebot tool. Can be
disabled by giving a special value `NONE`.
Default: output.xml
-l --log file HTML log file. Can be disabled by giving a special
value `NONE`. Default: log.html
Examples: `--log mylog.html`, `-l NONE`
-r --report file HTML report file. Can be disabled with `NONE`
similarly as --log. Default: report.html
I suggest using -d argument. Indicate a different directory for each .robot file executing.
robot -d test1 test1.robot
BTW, why don't you execute them at the same time? You can see each log in one file.

Related

How to set the user define path for log/output/report file of robot framework on command line

I am using robot framework with pycharm.
I am running all the tests of my folder using
testfolder>robot .
I want to set the path of log/output/report file to my customized location.
I have change the path of screenshot as D:/Screenshot folder in my variables.robot.
But How to set the path for mentioned file?
I also wanted to know
What is the common to run on terminal/cmd to run all the scripts of same folder with defined log file path?
Robot Framework User Guide walks you through the Basic Usage in quite good detail. Additionally the same document contains a section for the Different Command Line Options Available where you can get quite good picture on the options you have available.
Specifically --outputdir or -d will make Robot to save Log.html, Report.html and output.xml to the specified folder.
As mentioned by #Morkkis, the -d or --outputdir would do the trick. Also, it works for both command line and PyCharm Arguments field
For the screenshots, you could use the screenshot_directory command line argument. Please, check the Keyworkd documentation for more details ScreenShot Library Documentation
Also, for the report/logs file location, you can use these variables:
${LOG LEVEL} Current log level.
${OUTPUT FILE} An absolute path to the output file.
${LOG FILE} An absolute path to the log file or string NONE when no log file is created.
${REPORT FILE} An absolute path to the report file or string NONE when no report is created.
${DEBUG FILE} An absolute path to the debug file or string NONE when no debug file is created.
${OUTPUT DIR} An absolute path to the output directory.

Muttrc: how to source a file in muttrc's directory

I have a muttrc file which sources a secondary file mutt-secrets which resides in its same directory. But I have what appear to be two conflicting needs:
Be free to reference the muttrc file from any working directory
Be free to move it (and mutt-secrets) without having to edit muttrc to change the source path for mutt-secrets
At present, the first line of my muttrc says: source mutt-secrets. That works fine when I run mutt from within the directory where the two file reside, but if I run mutt from elsewhere and reference muttrc with a -F flag, then mutt can find muttrc, but muttrc can't find mutt-secrets.
How can I solve this?
Use absolute paths. For example:
source ~/.mutt/mutt-secrets
TL;DR one-line solution:
source `lsof -c mutt -Fn | grep '/muttrc$' | sed 's|^n||; s|/muttrc$||;'`/mutt-secrets
or, if you want to reuse the muttrc directory, you can save it to a custom variable:
set my_muttrc_dir = `lsof -c mutt -Fn | grep '/muttrc$' | sed 's|^n||; s|/muttrc$||'`
source $my_muttrc_dir/mutt-secrets
If you want to see the output of the command when you launch mutt, you can put this line in your muttrc:
echo `lsof -c mutt -Fn | grep '/muttrc$' | sed 's|^n||; s|/muttrc$||'`
Assumptions: the Mutt process is called mutt and the Mutt's initialization file is called muttrc. Furthermore, you could get in trouble if you have more than one Mutt instance running (for example if you launch in parallel two or more Mutt instances with different initialization files, because the command may select the wrong path).
Explanation
The idea is to look for muttrc full path in the list of open files by Mutt. We can get this list using lsof command (it has to be installed in your system), then extract the full path by parsing the lsof output with grep and sed commands.
This approach is viable because Mutt's initialization files support the use of external command's output with backticks (``). When Mutt encounter and execute our command enclosed in backticks (``), it is in the process of reading the muttrc file, so the muttrc file appears in the list of currently open files by Mutt. This enables us to use the lsof command.
lsof parameters
-c mutt: list open files of process named mutt;
-Fn: for each element, print only the name (it is the path in our case). Because of lsof output format, the path will be prefixed with the character n.
grep and sed
We use grep to select the line which contains muttrc file path, assuming the filename is exactly muttrc. Then we clean the lsof output with sed by both removing the n character at the beginning of the line and the /muttrc string from the end of the line. This way we get the path of the directory containing the muttrc file.
There is a cleaner solution?
Mutt expands relative paths inside initialization files from its current working directory, i.e. from the directory you launch Mutt. It supports a mechanism that allows path's expansion relatives to something different, but the "initialization file directory" or something similar are not available. See here.
I neither found a way to get the -F <path> option you pass to the mutt command inside the initialization file.
References
backticks in Mutt's initialization file;
current directory;
_mutt_buffer_expand_path, source code
source_rc, source code
source_rc call, source code
Tested with: Mutt 2.0.5, lsof 4.93.2, GNU grep 3.7, GNU sed 4.7.

Error in running trace32 with command line

I have a .cmm file which helps in debugging of Qcomm chipsets.
This file has a line : cd ../../../../../modem_proc
When I run this same cmm file using T32 GUI, it runs fine and does the work. But when I am trying to run the same file using windows command line using,
C:\T32\bin\windows64>t32mqdsp6.exe -c C:\T32\config.t32 -s D:\path\to\xxx.cmm
Following error is thrown in T32: syntax error in B::cd ../../../../../modem_proc
What am I missing here? I have no hands-on experience with T32 what-so-ever.
The problem probably results from different working directories. Type
PRINT OS.PWD()
in the GUI and add it to the top of the script. I'd suspect they are different.
Don't use working directory relative paths, instead use paths relative to the script, e.g.
CD ~~~~/../../../../modem_proc
The four tilde (~) symbols mean "directory of the currently executed script". There's still a possible issue with this solution when using multiple GUIs and the intercom, but for most use-cases this should be OK.
When starting TRACE32 (up to build 99518) without option "-s", it starts a default script t32.cmm form your TRACE32 installation directory. But t32.cmm is not executed, when "-s" is used.
So probably your t32.cmm is changing your working directory. If so you can fix the issue by adding the line
DO ~~/t32.cmm
to the top of your script xxx.cmm.
See also https://www.lauterbach.com/frames.html?help_autostart.html
The default working path is also set by the TRACE32 configuration file. That is the file passed with "-c". So if your are using a different configuration file than C:\T32\config.t32 when starting your TRACE32 GUI the normal way, then you should use that configuration file also when starting TRACE32 from the command line.
To get the path of the configuration file usually used, start TRACE32, execute command AREAand then command PRINT OS.PCF()
Furthermore dev15 is probably right here https://stackoverflow.com/a/53671657/4727717:
Use paths relative to the PRACTICE script (cmm-file) by starting each path with four tildes.

How to auto save Nunit tests result in html file?

I am using Nunit extension with Selenium tests in Visual Studio 2012.
Nunit has an option to save results in txt, xml or html files.
But what I want to do is to automatically save results in html after every test complited.
Updated Approach :
Save below lines as a batch file and call this at the end of TearDown method in your test case or test suite. The batch file will take 3 parameters, path to testresult.xml generated by nUnit, path where this xml has to be copied (make sure folder exists), path to output html file to be generated.
Batch file will wait until xml is generated from nUnit , then converts it.
I'm using NUnit2Report.Console for converting xml to html. You can get it from Nuget.
#ECHO Waiting for the file %1 to be generated.
:CheckForFile
#ECHO THIS WINDOW WILL BE CLOSED AUTOMATICALLY. DO NOT CLOSE IT.
if exist %1 goto FileExists
ping -n 10 localhost >NUL
goto :CheckForFile
:FileExists
copy %1 %2
"NUnit2Report.Console.Runner.1.0.0.0\NUnit2Report.Console.exe" --fileset=%2 --out %3

Input Error when running WSH script

I'm trying to run WSH script using cscript specifically
in cmd I got this Error
Input Error: There is no script file specified.
using this command
cscript c:\file.wsh
On windows 7 ultimate
My WSH script simply writes a registry entry
I don't want to use vbscript (.vbs) or wscript engine
so how can I make my WSH script work ?
.WSH
The Windows Script Host control file (.wsh) is a text document in which you can customize the execution of one or more of your scripts. It is created automatically when you set the properties for a supported script file.
The following example illustrates a typical .wsh file:
[ScriptFile]
Path=C:\WINNT\Samples\WSH\showprop.vbs
[Options]
Timeout=0
DisplayLogo=1
BatchMode=0
The path information in the [ScriptFile] section identifies the script file that is associated with the .wsh file. The keys in the [Options] section correspond to settings in the Script tab within the Properties dialog box.
Note:
You must have the original script file present when executing the .wsh file. If the .wsh file fails to run the script, check the Path= information in the .wsh file to ensure that it points to the script you are attempting to run.
When you double-click a .wsh file or run it from the command line, CScript.exe or WScript.exe reads the .wsh file to determine the specific settings that should be used to execute the script. CScript/WScript executes the original script, passing in the properties that are defined within the .wsh file.
It's not possible to specify script parameters with the .wsh file. You must run the script (either the script file or the .wsh file) from a command prompt to add the parameters.
Resource: Setting and Customizing Script Properties (.wsh)