Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a variable into a file?

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.

like image 889
mia Avatar asked Dec 20 '22 05:12

mia


1 Answers

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}
like image 190
Laurent Bristiel Avatar answered Dec 28 '22 07:12

Laurent Bristiel