【问题标题】:how to return a string using robot framework如何使用机器人框架返回字符串
【发布时间】:2019-11-27 08:22:09
【问题描述】:

我创建了一个连接两个字符串并返回新字符串的关键字,但是有一些我无法理解的错误。

Set error
   [Arguments]  ${userName}  ${error}
   ${errorStr}  Catenate  ${error}  ${userName}
   log to console  ${errorStr}   #->works 'No value in database for John'
   [Return]  ${errorStr}

但是当返回时,我有这个错误:

评估表达式“John 的数据库中没有值”失败:SyntaxError: invalid syntax (, line 1)

【问题讨论】:

  • 您的代码对我有用,除了以[Arguments] 开头的行缩进正确。当我修复它并调用Set error john No value in database for 时,它按预期工作。请显示完整的minimal reproducible example - 我们不需要任何数据库代码,只需要足够的代码来显示您如何调用此关键字并使用返回值。

标签: robotframework


【解决方案1】:

试试这样。

[Arguments]      ${userName}  ${error}
${errorStr}=     Catenate    SEPARATOR= \     ${error}      ${userName}
Log              ${errorStr}      #->works 'No value in database for John'
[Return]         ${errorStr}

【讨论】:

    猜你喜欢
    • 2021-01-16
    • 2021-11-24
    • 1970-01-01
    • 2020-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-01
    相关资源
    最近更新 更多