Overwriting a global variable with keyword result

Hey,

So I have the following case with Some Global Variable that I want to overwrite in one of my tests with a result that is being returned from a keyword.

at first I used this
${Some Global Variable} = Some Keyword

but soon realized that my original variable is being shadowed and not overwritten, so I adjusted it like this

${tmp} = Some Keyword
Set Global Variable ${Some Global Variable} ${tmp}

which sets my global variable to the correct value but seems a bit clumsy, so is there a better way to do this?

Thanks in advance

Hi Mohamed,

${tmp} =    Some Keyword
Set Global Variable    ${Some Global Variable}    ${tmp}

Doing this is the correct way :+1:.

Unless you use a Set something Variable keyword then all variables are local scope by design it’s explained here → Variable scopes

Dave.

2 Likes