undertale
undertale

Reputation: 452

robot framework selenium check link

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

Upvotes: 2

Views: 1005

Answers (1)

Bence Kaulics
Bence Kaulics

Reputation: 7281

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

Upvotes: 4

Related Questions