I want to compare two string using Evaluate (builtIn keyword in robotframework). In this test I am connecting to router and trying to execute cisco command ( show route local) , and I want to compare the output of this command to a given string in order to do the if statement.
Write show route local
${output} = Read delay=0.5s
${output1} = Read delay=0.5s
${status} = Evaluate "${output1}" = "% Ambiguous command: "show route local""
IF ${status}= True
Write show route local connected
${output} = Read delay=0.5s
Set Suite Variable ${G_stdout} ${output}
ELSE
Log to Console ${output1}
Set Suite Variable ${G_stdout} ${output1}
END
This error appears when I execute the test :
ModuleNotFoundError: No module named '"showroutelocal""'
The error is because your string has more than one consecutive space, so robot thinks
"show route local"
is an extra argument representing the name of a module to be imported.To fix that, you need to escape one of the spaces in the string on the right hand side of the equation. There are other problems with your expression as well. Here's a version that works:
The things I changed:
==
instead of=
$output1
instead of"${output1}"
, since${output1}
itself has double quotes in it which would cause a syntax error