如何删除机器人框架中的临时文件?

how to delete Temp files in robot framework?

*** Settings ***
Library    Process    
*** Test Cases ***
Temp files clear
    Run Process    del    %TEMP%    /*.*    /s    /f    /q    

----------------------------------------------------------------
FAIL    FileNotFoundError: [WinError 2] The system cannot find the file specified
-----------------------------------------------------------------

我正在使用 Windows10。 如何解决这个错误?

您可以使用 Remove File from the OperatingSystem 库来达到同样的目的:

Remove File    ${TEMPDIR}${/}*.*

rasjani 的评论实际上让我开始思考 - 尝试使用 shell=${True} 调用 Run Process

Run Process    del    %TEMP%/*.*    /s    /f    /q     shell=${True}

评论让我想起了什么from the official docs of subprocess:

On Windows with shell=True, the COMSPEC environment variable specifies the default shell. The only time you need to specify shell=True on Windows is when the command you wish to execute is built into the shell (e.g. dir or copy). You do not need shell=True to run a batch file or console-based executable.