Reputation: 85
If I pass the string ${varName}
to the built in keyword Log to Console
, the console outputs the literal string ${varName}
. If there is a variable named varName
with a value of test123
, how do I get the keyword Log to Console
to output the variable value of test123
when I pass in ${varName}
?
I'm making a data-driven script from an Excel spreadsheet. In the string values I'm passing in, there are variables names within it that I want replaced with the variable's value.
I've tried to run the string through the Evaluate
keyword, but it just changes all of the variable names like ${varName}
to RF_VAR_varName
, so it's recognizing something here?
Open Excel ${ExcelFile}
${varName} Read Cell Data By Coordinates ${Sheet_Name} 0 ${RowNum}
set global variable ${varName}
log varName: ${varName} console=yes
Would output to the console:
'38773461|${TMS_ConfNo}|substr:RDSJUMHV FIRSTNAME|${globalLastName} FIRSTNAME|fullline:JEYCTINY, FIRSTNAME|${globalLastName1}, FIRSTNAME|fullline:RDSJUMHV, FIRSTNAME|${globalLastName}, FIRSTNAME|fullline'
I would like this string:
'38773461|${TMS_ConfNo}|substr:RDSJUMHV FIRSTNAME|${globalLastName} FIRSTNAME|fullline:JEYCTINY, FIRSTNAME|${globalLastName1}, FIRSTNAME|fullline:RDSJUMHV, FIRSTNAME|${globalLastName}, FIRSTNAME|fullline'
To evaluate into this:
'38773461|12345678|substr:RDSJUMHV FIRSTNAME|LASTNAME FIRSTNAME|fullline:JEYCTINY, FIRSTNAME|LASTNAME1, FIRSTNAME|fullline:RDSJUMHV, FIRSTNAME|LASTNAME, FIRSTNAME|fullline'
I would like all variables in the string to translate to their respective value.
Upvotes: 2
Views: 1229
Reputation: 385970
Robot has a built-in keyword named Replace variables which will replace variables with their values in a string.
Upvotes: 4