robot framework selenium check link

Viewed 372

how can i run keyword only if specific link is exist in the page, and if the link not exist continue the test as usual ? I tried like this but it does not work

${Result}=  Page Should Contain Link  ${link}
run keyword if  '${Result}'=='PASS'  Get Rid of Messages

and the link exist in the page

1 Answers

What you are looking for is the Run Keyword And Return Status keyword from the BuiltIn library.

Runs the given keyword with given arguments and returns the status as a Boolean value.

This keyword returns Boolean True if the keyword that is executed succeeds and False if it fails. This is useful, for example, in combination with Run Keyword If. If you are interested in the error message or return value, use Run Keyword And Ignore Error instead.

${passed}=    Run Keyword And Return Status    Page Should Contain Link    ${link}
Run Keyword If    ${passed}   Get Rid of Messages
Related