0

I have the following Robot Framework keyword, designed to get the full path of the "Downloads" directory in Windows:

Get Download Directory
    ${user_home_dir}=   Get Environment Variable    UserProfile
    ${download_dir}=    ${user_home_dir}\\Downloads
    [return]    ${download_dir}

This is being assigned to a variable:

${download_dir}                         Get Download Directory

However, it seems that the proper value is not being assigned. The following:

Log To Console                      "Download directory: " ${download_dir}

logs "Download directory: " Get Download Directory to the console. Why is this the case?

Note that the assignment to the ${download_dir} variable is being made in the *** Variables *** section.

1
*** Test Cases ***
One Return Value
    ${ret} =    Return One Value    argument

Multiple Values
    ${a}    ${b}    ${c} =    Return Three Values
    @{list} =    Return Three Values
    ${scalar}    @{rest} =    Return Three Values

*** Keywords ***
Return One Value
    [Arguments]    ${arg}
    ${value}=    Set Variable    1
    [Return]    ${value}

Return Three Values
    [Return]    foo    bar    zap

you have to use set variable keyword to set a variable,

            ${download_dir}=    Set Variable    ${user_home_dir}\\Downloads
            [return]    ${download_dir}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.