How to write a variable into a file?

后端 未结 2 1949
旧时难觅i
旧时难觅i 2020-12-30 16:28

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

E.g. If ${Username} equals 0401190926729000, this value will be sto

2条回答
  •  遥遥无期
    2020-12-30 17:14

    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}
    

提交回复
热议问题