I want to run Keyword if Element is visible. E.g I want to check that if a button is visible on the page then run particular Keyword. Below is my code. Create button is Keyword and want to run if CreateButton is visible on the page otherwise not.

Create Button
    Sleep    10s
    Click Element    ${CreateButton}

Create Case with Subject
    Sleep    15s
    ${CreateButtonVisible} =    Page Should Contain Element    ${CreateButton}
    Run keyword If    ${CreateButtonVisible}    Create Button

2 Answers 2


It seems like you don't want to report error if element was not found. In such case, the most straight-forward way is to run the keyword and ignore errors if element is not found:

Run Keyword And Ignore Error    Click Element    id=element_id

Also, hard-coding sleep intervals can make your tests slow and flaky. Using Wait Until Page Contains is better.


Based on the example of RF keywords list, you should write the condition, in your case should be ${CreateButtonVisible} == 'PASS'.

Run Keyword If  ${CreateButtonVisible} == 'PASS'    Create Button
  • You probably will need quotes around the first part of the expression: '${CreateButtonVisible}' == ... Aug 9, 2014 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.