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.
Is there some condition like this or is it necessary to write by myself somehow?
By locating the element using xpath, I assume that you're using Sselenium2Library
. In that lib there is a keyword named:
Page Should Contain Element
which requires an argument, which is a selector
, for example the xpath that defines your element.
The keyword failes, if the page does not contain the specified element.
For the condition, use this:
${Result}= Page Should Contain Element ${Xpath}
Run Keyword Unless '${RESULT}'=='PASS' Keyword args*
You can also use an other keyword: Xpath Should Match X Times