I have to validate an UI object that is not-clickable. In UIautomator, for that element clickable is False. So I want validate that in script. Please give me idea for the same.
1 Answer
You could use the Run Keyword And Return Status from the BuiltIn library to run another keyword and see if it succeeds or not without failing the test case itself.
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 andFalse
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. (...) Errors caused by invalid syntax, timeouts, or fatal exceptions are not caught by this keyword. Otherwise this keyword itself never fails.
A possible example would be:
*** Keywords ***
Element Should Not Be Clickable
[Arguments] ${element}
${status}= Run Keyword And Return Status Click Element ${element}
Run Keyword If 'True'=='${status}' Fail "Element should not be clickable"