如何将变量写入文件? [英] How to write a variable into a file?

查看:70
本文介绍了如何将变量写入文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

推荐答案

这是一个提案:

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

这篇关于如何将变量写入文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆