Robotframework: How to evaluate boolean value returned from Javascript call
<p>I was quite puzzled that this failed with a <code>NameError</code>:</p>
<pre><code>${val} =    Execute Javascript    return sessionStorage.isMatching    
Should Be True     ${val}
</code></pre>
<p>Log output was:</p>
<pre><code>INFO Executing JavaScript:
INFO ${val} = true 
KEYWORD  BuiltIn . Should Be True ${val} 
TRACE Arguments: [ 'true' ] 
FAIL Evaluating expression 'true' failed: NameError: name 'true' is not defined 
</code></pre>
<p>This doesn't work neither:</p>
<pre><code>Should Be True     ${val} == true    --&gt;  Evaluating expression 'true == true' failed: NameError: name 'true' is not defined
Should Be True     ${val} == 'true'  --&gt;  Evaluating expression 'true == 'true'' failed: NameError: name 'true' is not defined
Should Be True     ${val} == &quot;true&quot;  --&gt;  Evaluating expression 'true == &quot;true&quot;' failed: NameError: name 'true' is not defined
</code></pre>
<p>After reading the docs I learned that underlying python doesn't evaluate JS <code>true</code> as <code>true</code>. I then tried to convert the boolean to String in JS:</p>
<pre><code>${val} =    Execute Javascript    return sessionStorage.isMatching.toString()
</code></pre>
<p>but I got a <code>NameError</code>, again.</p>
<p>The only way I know is this which looks awful (because I explicitly have to convert a boolean value to boolean):</p>
<pre><code>${val} =    Execute Javascript    return sessionStorage.isMatching
${bool} =    Convert To Boolean    ${val}
Should Be True     ${bool}
</code></pre>
<p>Is there a better way, to evaluate this in either RF or JS?</p>
<p>Versions:</p>
<blockquote>
<p>Python    2.7.8</p>
<p>Robotframework    3.0</p>
</blockquote>