robotframework – 如何将变量写入文件?

我想在输出文件中存储${Username}值:

例如.如果${Username}等于0401190926729000,则此值将存储在文件中.

最佳答案
这是一个提议:

*** Settings ***
Library  OperatingSystem
Library  String

*** test cases ***
write_variable_in_file
  ${Username} =  Generate Random String  1  abc
  log to console   ${Username}
  run keyword if  '${Username}' == 'a'   write_variable_in_file  ${Username}

*** Keywords ***
write_variable_in_file
  [Arguments]  ${variable}
  Create File  ${EXECDIR}/file_with_variable.txt  ${variable}

转载注明原文:robotframework – 如何将变量写入文件? - 代码日志