Both your tests would import the resource file and be able to use the variables/methods within. This assumes the variable will remain the same throughout your tests.
If you append under variables its working. Pls check keywords.resource file
*** Settings ***
Resource variables.resource
*** Variables ***
${Login} ${url}/login.html
${logout} ${url}/logout.html
*** Keywords ***
Log my Sides
Log To Console This logs the two variables:
Log To Console ${Login}
Log To Console ${logout}
The problem is, that if you import that resource file with your keyword, that keyword is not yet executed…
So the created variables just have not set variables in there.
You have to call the actual keyword, that calculates google or yahoo…
Now the variable ${url} is globally set, now you can use it.
But this means, you have to resolve it now.
The variables section has already tried to read it way before that time! so no values there.
You can accomplish that by using the variable as string with a backslash escaped and the replace it with its value after you called the set keyword.
And by the way, you do not need to set ${url} at the variables section if you run that keyword.
In your situation before it was just that the variable ${url} is never set by your code, so adding that to the *** Variables *** did just cause an error less.
But when calling that setter thing, everything is fine.