【问题标题】:Robot FrameWork - Get Current Date Issue - No keyword with name '=' found机器人框架 - 获取当前日期问题 - 未找到名称为“=”的关键字
【发布时间】:2020-11-23 13:09:50
【问题描述】:

我正在尝试使用当前时间更新一个 Excel 文件中的列。

为了完成它,我使用来自 DateTime 库的 Get Current Date 关键字并将其存储到下面脚本中的标量 ${datetime}

 *** Settings ***
 Default Tags      Download_File
 Library           SeleniumLibrary
 Library           ExcelLibrary
 Resource          Userdefinedkeywords.txt
 Library           DateTime

 Run Keyword If    ${countt}>0    Run Keywords    Click Element    xpath://[@id="fileSubmit"]/div[1]/img
    ...    AND    Open Excel    D:\\RPA\\Demo\\Excelx.xls
    ...    AND    Put String To Cell    Test    2    ${countd}    ZIP FILE
    ...    AND    Save Excel    D:\\RPA\\Demo\\Excelx_DONE.xls
    ...    ELSE IF    ${countt2}>0    Run Keywords    Click Element    xpath://*[@id="plsAttachGrid_0_1"]/img
    ...    AND    ${datetime}=    Get Current Date
    ...    AND    Open Excel    D:\\RPA\\Demo\\Excelx.xls
    ...    AND    Put String To Cell    Test    2    ${countd}    SINGLE FILE
    ...    AND    Put String To Cell    Test    3    ${countd}    ${datetime}
    ...    AND    Save Excel    D:\\RPA\\Demo\\Excelx_DONE.xls
    ...    ELSE    Run Keywords    Open Excel    D:\\RPA\\Demo\\Excelx.xls
    ...    AND    Put String To Cell    Test    2    ${countd}    NO FILE
 ${countd}=    Evaluate    ${countd}+${1}

我收到以下错误:

FAIL : No keyword with name '=' found.

部分代码运行时:

... AND ${datetime}= Get Current Date

代码有什么问题? 提前致谢

【问题讨论】:

    标签: python-2.7 datetime robotframework


    【解决方案1】:

    你不能在 Run Keyword If 中进行变量赋值 - 它只运行关键字,而这正是框架抛出错误的原因。

    Run Keyword If    ${countt}>0    Run Keywords    Click Element    xpath://[@id="fileSubmit"]/div[1]/img
    # skipped lines
        ...    AND    ${datetime}=    Get Current Date
        ...    AND    # skipped lines
    

    当它到达该行时,它尝试运行带有参数“获取当前日期”的关键字${datetime}=,但失败了。

    【讨论】:

      猜你喜欢
      • 2019-01-01
      • 1970-01-01
      • 2015-08-12
      • 2019-12-21
      • 2017-09-18
      • 1970-01-01
      • 2019-07-04
      • 1970-01-01
      • 2015-01-10
      相关资源
      最近更新 更多