如何将变量写入文件?

时间:2015-04-01 17:33:23

标签: robotframework

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

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

2 个答案:

答案 0 :(得分:8)

以下是提案:

*** 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}

答案 1 :(得分:-1)

linux: 运行echo“ $ {Username}”> / tmp / foo