1

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
  • What sort of object are you asking about? A native UI element, an element on a web page, something else? – Bryan Oakley Dec 10 '18 at 22:47
1

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 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. (...) 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"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.