Robot Framework If element is visible execute a keyword

PurpleBeni picture PurpleBeni · Jun 3, 2015 · Viewed 24.8k times · Source

I have a page that may and may not contain a certain element that will affect all the xpaths.

I need to run a "Run Keyword If" to identify if this element exists and if so to execute another keyword.

I tried to set the "Page Should Contain Element" and "Element Should Be Visible" as variables and pass it in the If statement but it only return None.

What can I use to identify an element in a page?

Answer

Bruno Bossola picture Bruno Bossola · Oct 29, 2015

I experienced the same issue, I use this solution:

${present}=  Run Keyword And Return Status    Element Should Be Visible   id=my-element
Run Keyword If    ${present}    My Cool Keyword