简体   繁体   中英

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.

To accomplish it, I'm using Get Current Date keyword from DateTime Library and store it to the scalar ${datetime} on the script below

 *** 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    ${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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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