How to capture error message in android native app

I have a android native app. If i login to app without user name and password it gives the error message at below of the page where I can inspect the element. Please suggest me to achieve this.

@ ramshankar_testing You can do it in two ways -
One find out the ID of that error toast. Then check if the element is displayed.

Second, check if the “error string” is displayed in screen.

@RamS, Thanks for your quick reply.

First Way: I tried this way but I am not able to locate this element in Inspector.
SecordWay. I am checking the error string whether the pagesource contain or not. But the pagesource does not have this string. Even manually I printer the driver.getpagesource() after clicking submit button. But it does not display anything about the error message.

I am guessing the error string is a toast message and it last few seconds. In that case, you just keep the sign in page loaded, run uiautomatorviewer from sdk/tools directory.

And be real quick to take hierarchy view when ever toast appears.

BTW, is it native page or webview?

It is native page. I tried to to capture the error message in uiautomatorviewer but the hierarchic does not show this element but it shown the error toast message in the screen.

I think error toast message we can not inspect by uiautomator.I red it from other source.

Have you ever tried to inspect this type of android OS error toast message ?

One solution I got that image verification but it is more complicated.

Hi Ramshankar,

uiautomator still doesn’t support toast. I think selendroid supports them. I think appium team is looking to bring support for toast with uiautomator.

Errors need not be only related to toast.

In our project, we are finding it hard to capture validation errors thrown from edittexts… [This error message is set by EditText api, EditText.setError()]

I tried with selendroid, but selendroid inspector also not able to find the element id or anything for toast message.

Hi @ramshankar_testing ,

Are you able to share your native app, or at least a basic implementation of said “screen”? I can help you to debug and find a way to properly handle the toast.

Hi Ram,

First of all we can not get the identification of this element (error message). As this is dynamic.
Second this will not be identified as error string ever (as this is toast message, not like error message).

@Cesar,

Thanks for your reply. I will be able to share my app. Can I have your email - id please ?

Were you able to find a way to check error messages seen on the screen created by EditText.setError() as mentioned above?

Any luck to deal with EditText.SetError(), error icons