0

Could you please help me out that how Run Keyword If works in RIDE?

I want to click the "EXIT" button if there is any online error in the page after clicking on "Create" Button. I have put the code like this. But it did not work. After running, the test case did not fail but at the same time, the EXIT button was not clicked also.

Click Button    xpath=//*[@id="divHeader"]/table/tbody/tr/td[5]/input

${Result}    Page Should Contain Element    //*[@id="divError"]

Run Keyword If    '${Result}'=='PASS'    Click Button    xpath=//*[@id="MyForm"]/div[4]/table/tbody/tr/td[2]/input

Expected: As there is an online error, It should click the "Exit" button.

1 Answer 1

3

Page should contain doesn't return a result. It either throws an exception or returns None.

If you need to get the pass/fail status of a keyword you need to use Run keyword and return status. However, it doesn't return "Pass" or "Fail". It returns the a boolean (either True or False).

${result}  Run keyword and return status
...  Page should contain element  //*[@id="divError"]

You can use the value directly as the condition in Run keyword if, like the following:

Run keyword if  ${result}
...  Click Button    xpath=//*[@id="MyForm"]/div[4]/table/tbody/tr/td[2]/input     
Sign up to request clarification or add additional context in comments.

1 Comment

@ApratimChaudhuri You should log ${result} to make sure it is what you think it is.

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.