【问题标题】:Put report files in custom folder at end of execution在执行结束时将报告文件放在自定义文件夹中
【发布时间】:2020-01-22 14:42:42
【问题描述】:

在每次机器人执行结束时,我想将以下文件:Log.xml、Report.xml、Output.xml 放在一个唯一的时间戳目录中。

我的脚本给文件加上时间戳,但我真的不想要,只是每次执行后时间戳目录中的默认文件名?

这是我当前的脚本:

   CALL "C:\Python27\Scripts\robot.bat" --variable BROWSER:IE --outputdir C:\robot\ --timestampoutputs --name "Robot Execution" Tests\test1.robot

【问题讨论】:

  • 为什么不删除--timestampoutputs并将时间戳目录添加到--outputdir C:\robot\
  • 我已经这样做了,它刚刚创建了一个名为 --timestampoutputs 的文件夹,里面有文件?这就是我所做的 --outputdir C:\robot\--timestampoutputs

标签: automated-tests robotframework


【解决方案1】:

时间戳需要在批处理脚本中生成。如果它还不存在,Robot Framework 将生成完整的路径。这也包括所有父文件夹。

当我们站在巨人的肩膀上时,这个答案也是以Stack Overflow answer 的形式提供的,它提供了以下脚本栏的最后两行

@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
:: put your desired field delimiter here.
:: for example, setting DELIMITER to a hyphen will separate fields like so:
:: yyyy-MM-dd_hh-mm-ss
::
:: setting DELIMITER to nothing will output like so:
:: yyyyMMdd_hhmmss
::
SET DELIMITER=%1

SET DATESTRING=%date:~-4,4%%DELIMITER%%date:~-7,2%%DELIMITER%%date:~-10,2%
SET TIMESTRING=%TIME%
::TRIM OFF the LAST 3 characters of TIMESTRING, which is the decimal point and hundredths of a second
set TIMESTRING=%TIMESTRING:~0,-3%

:: Replace colons from TIMESTRING with DELIMITER
SET TIMESTRING=%TIMESTRING::=!DELIMITER!%

:: if there is a preceeding space substitute with a zero
SET DATETIMESTAMP=%DATESTRING%_%TIMESTRING: =0%

CALL robot --variable BROWSER:IE --outputdir ./%DATETIMESTAMP%/ --name "Robot Execution" ./test.robot 

【讨论】:

    猜你喜欢
    • 2019-04-09
    • 1970-01-01
    • 1970-01-01
    • 2013-01-04
    • 2011-12-07
    • 2023-04-01
    • 1970-01-01
    • 2011-12-15
    • 2022-11-17
    相关资源
    最近更新 更多