2

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

3
  • How the html code of element looks like? Please read minimal reproducible example and how-to-ask and edit your post accordingly. Commented Oct 1, 2020 at 15:19
  • <div class="messageLinkStyle"><a>Close these 2 messages</a></div> Commented Oct 1, 2020 at 15:29
  • and i give the ${link} value of the xpath of <a>Close these 2 messages</a> Commented Oct 1, 2020 at 15:30

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.