简体   繁体   English

机器人框架 - 获取当前日期问题 - 未找到名称为“=”的关键字

[英]Robot FrameWork - Get Current Date Issue - No keyword with name '=' found

I'm trying to update a column on one Excel File with the Current Time.我正在尝试使用当前时间更新一个 Excel 文件上的列。

To accomplish it, I'm using Get Current Date keyword from DateTime Library and store it to the scalar ${datetime} on the script below为了完成它,我使用来自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}

I'm getting the following error:我收到以下错误:

FAIL: No keyword with name '=' found.

When the part of the code is run:当部分代码运行时:

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

What is wrong on the code?代码有什么问题? Thanks in advance提前致谢

You cannot do variable assignment inside Run Keyword If - it only runs keywords, and this what the framework throws an error for.您不能在 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

When it gets to that line, it tries running a keyword ${datetime}= with argument "Get Current Date", and fails.当它到达该行时,它尝试运行带有参数“获取当前日期”的关键字${datetime}= ,但失败了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM