How to write a variable into a file?

2019-02-07 15:51发布

I would like to store ${Username} value in an output file:

E.g. If ${Username} equals 0401190926729000, this value will be stored in a file.

2条回答
Viruses.
2楼-- · 2019-02-07 15:59

linux: Run echo "${Username}" > /tmp/foo

查看更多
看我几分像从前
3楼-- · 2019-02-07 16:09

Here is an proposal:

*** 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}
查看更多
登录 后发表回答