You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Robot Framework中如何将长参数拆分为多行?

Robot Framework长参数多行拆分的正确方法

要把长参数拆分成多行且不被识别为多个参数,有两种可靠的实现方式:

方法一:使用三重引号包裹多行文本

这是最直观的方式,适合包含换行的长文本参数,Robot Framework会自动将三重引号内的所有内容视为单个字符串,保留换行格式。

示例代码:

*** Settings ***
Documentation    Hello world example.
Library          Dialogs

*** Test Cases ***
Hello world Test
    [Documentation]    My simple test
    Execute Manual Step    """This is first line and here goes the second.
My second have xxx xxx
It seems it is not possible to split this in the code..."""
    Execute Manual Step    Has it been working in previous step?

方法二:严格对齐续行内容

如果不想用引号,需要确保续行的内容与前一行参数的起始位置严格对齐,Robot会自动将这些行的内容拼接成一个参数。

示例代码:

*** Settings ***
Documentation    Hello world example.
Library          Dialogs

*** Test Cases ***
Hello world Test
    [Documentation]    My simple test
    Execute Manual Step    This is first line and here goes the second.
    ...                    My second have xxx xxx
    ...                    It seems it is not possible to split this in the code...

注意:...后面的文本必须和前一行中参数的第一个字符(比如示例里的This)起始位置完全对齐,避免被识别为新参数。

内容的提问来源于stack exchange,提问作者Roman Pavelka

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 23:51:02