Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to determine a button is disabled with native android automation/Java

I am performing some appium automation on a native android app and I am stuck with the following situation:

I have a login button which has the following characteristics (see screenshot attached). Now no matter if the login button is enabled or disabled, those characteristic you see in the screenshot don't change. This is a problem as I want to test that the login button is disable based on certain text entry criterias.

I am unsure if something else is driving the login button where it is enabled or disabled (by the way whether the button is enabled or disabled, it visually looks the same).

Does anybody have any ideas on how I can tackle this? If I cannot do anything in regards to checking the button, the only thing I can think of (if it is possible) is to somehow determine after I click the login button that I remain on the same page (maybe wait for no retry message to be displayed as well as checking the login button remains on the page).

Thanksenter image description here

like image 675
BruceyBandit Avatar asked Nov 06 '22 18:11

BruceyBandit


1 Answers

Actually, Appium does support this kind of check: element/:element_id/enabled

MobileElement element = (MobileElement) driver.findElementByResourceId("login_submit");
boolean isEnabled = element.isEnabled();

If still always returns you the same result I suggest checking the source code of your app to make sure property is set properly. It is much better to fix the App for testability instead of the hacky check by clicking.

like image 63
dmle Avatar answered Nov 09 '22 14:11

dmle