Robotframework 在变量定义中使用变量

Robotframework 在变量定义中使用变量,robotframework,Robotframework,我试图将变量转换为变量,但它不起作用。我搜索了谷歌,尝试了很多东西,但都没有成功。 我希望这个问题不是“愚蠢的”: 我做错了什么 *** Settings *** Library SeleniumLibrary Library OperatingSystem *** Variable *** ${year} Get Time return year ${month} Get Time return mon

我试图将变量转换为变量,但它不起作用。我搜索了谷歌,尝试了很多东西,但都没有成功。
我希望这个问题不是“愚蠢的”:
我做错了什么

*** Settings ***
Library           SeleniumLibrary
Library           OperatingSystem

*** Variable ***
${year}           Get Time    return year
${month}          Get Time    return month
${day}            Get Time    return day
${output}         ${CURDIR}\Testing\Tests\SRV\csdb_@{year}-@{month}-@{day}.log

*** Testcases ***    
Textfile should have a line saying the service is started
    ${errors} =    Grep File    ${output}    Test
从:

最常见的变量源是测试用例中的变量表 文件和资源文件。变量表很方便,因为它们 允许在与测试其余部分相同的位置创建变量 数据,并且所需的语法非常简单它们的主要缺点 值始终是字符串,无法创建 动态。

为了做您想要做的事情,您需要在关键字中定义变量。例如:

*** Keywords ***
Get Output
    ${year}=      Get Time    year
    ${month}=     Get Time    month
    ${day}=       Get Time    day
    ${output}=    Set variable    ${CURDIR}/Testing/Tests/SRV/csdb_${year}-${month}-${day}.log
    [Return]      ${output}


*** Testcases ***    
Textfile should have a line saying the service is started
    ${output}=     Get Output
    ${errors} =    Grep File    ${output}    Test
注意:您可以在对关键字的一次调用中获取所有三部分数据,如下所示:

${year}  ${month}  ${day}=  Get Time    year month day

使用空格分隔格式阅读有点困难,但是变量名必须用两个或更多的空格分隔,但是“年-月-日”应该只有一个空格

谢谢你的回答!似乎我需要更多的基础知识-我不确定***关键字***和***变量***之间的区别,但现在我知道了。