How to check if button/widget on mobile app is disabled/enabled

Hi,

How can I check if a widget or button on a mobile app is disabled or enabled? Thanks.

Try this :slight_smile: This solution worked for me…

Here, expectedAttribute value you can pass enabled or disabled

@Keyword
verify_buttons_enabled_attribute_value(String expectedAttribute){
boolean enabledValue = isElementEnabled(testObject))
if(expectedAttribute.equalsIgnoreCase(“enabled”)){
Assert.assertTrue(enabledValue, buttonText +" button is not " + expectedAttribute)
}
if(expectedAttribute.equalsIgnoreCase(“disabled”)){
Assert.assertFalse(enabledValue, buttonText +" button is not " + expectedAttribute)
}
}

@Keyoword
boolean isElementEnabled(TestObject testObject) {
mobileElement = findMobileElement(testObject)
mobileElement.isEnabled()
}