Robot Framework - check if element defined by xpath exists
<p>I'm wondering, I'd love to find or write condition to check if some element exists. If it does than I want to execute body of IF condition. If it doesn't exist than to execute body of ELSE.</p>

<p>Is there some condition like this or is it necessary to write by myself somehow?</p>

<p>By locating the element using xpath, I assume that you're using <code>Sselenium2Library</code>. In that lib there is a keyword named: </p>

<p><code>Page Should Contain Element</code> which requires an argument, which is a <code>selector</code>, for example the xpath that defines your element. </p>

<p>The keyword failes, if the page does not contain the specified element. </p>

<p>For the condition, use this: </p>

<p><code>${Result}= Page Should Contain Element  ${Xpath}
Run Keyword Unless  '${RESULT}'=='PASS'  Keyword args*</code></p>

<p>You can also use an other keyword: <code>Xpath Should Match X Times</code></p>

python testing xpath automated-tests robotframework