Verifying Toast


#1

Hi,
I am new to appium and automation testing.
i’m testing a native android app and in the app there are a lot of Toast reactions.
is there a way to verify those toasts via appium?
I heard it can be done by moving to selendroid mode. is is true?
and if it is, how do i do it?


How to deal with android toast by appium
How to get xpath or Id of android toast
How can i get the text from this pop up and doing the compare with the expect result
#2

I was able to get toast messages working via the following general steps:

  1. Perform action to trigger the toast message to appear on screen
  2. Take x number of screenshots
  3. Increase resolutions of all screenshots
  4. Use tessearct OCR to detect the toast message.

#3

@alangithubtrader: Can you please explain in depth how to achieve that?


#4

I am assuming you need help on step2?

I have a configurable value for taking the number of screenshots, let’s call this ‘x’.

Then all I do is simply loop and take x number of screenshots after step1. Then I save all these screenshots into a directory.

The reason why I take all the screenshots first and then save the screenshots after loop is done is to increase my chance of catching the toast message in my screenshots.

Does this help?


#5

Yes thanks. It did helped.
One last question.
How to achieve step 4?


#6

For step 4,

these links really helped me.

https://code.msdn.microsoft.com/windowsdesktop/How-to-use-Tessnet2-library-716be12f


From when Appium is going to support identification and automation of toast messages?
#7

Here is an implementation code for this in python. It could be easily adopted to other languages


#8

Please explain, how you used Tesseract OCR. I have downloaded but not not knowing that how to use?


#9

Please see the link i posted above. And if you already did, what specific part of using the Tesseract OCR you’re having trouble?


#10

I have installed Tessract ocr (version: 3.02.02). Now how i have to write in code? I am using appium+java.


#11

After you imported the OCR lib, are you seeing the new methods provided by the Tesseract OCR library?


#12

Hi Gourav ,

Did you find the Code in Java for verifying toast messages using Tessract ocr ?
If found could you please share the code as I am unable to get it.


How can we identify Toast Message in Android App using Appium?
Verify Notifications or Toast messages
#13

Here is the Java Implementation. I personally used it across platforms and it worked like a charm.


#14

HI Sahajamit,

Are your code successful for verifying toast message.


#15

Yes It worked for me.


#16

toast is system property,not handled by application. Toast messages can be instrument using espresso which is different instrumentation.
If test toast verification is on very high priority then you should not use appium or Uiautomator. Also one suggestion these kind of verifications need to be done in UI unit testing using Espresso or other tools which are much powerful tool than Appium (Provided you have access of application’s source code). Automation suites need to focus on regression e2e functionality, not on toast message or UI verification part.


#17

Priyank, I dont have source code of application? so cant we test toast?


#18

We can test without source code as well. Please check the below video for more details


Appium need to support Toast message
#19

is this possible if we use python?


#20

What is Verify() method doing? :slight_smile: