# Appium Toast Message not working with UIAutomator2 for Android

**URL:** <https://discuss.appium.io/t/appium-toast-message-not-working-with-uiautomator2-for-android/28510>\
**Category:** Support\
**Created:** [November 7, 2019, 4:17pm UTC](https://discuss.appium.io/t/appium-toast-message-not-working-with-uiautomator2-for-android/28510 "2019-11-07T16:17:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guru](https://discuss.appium.io/letter_avatar_proxy/v4/letter/g/ecae2f/32.png) [@Guru](https://discuss.appium.io/u/Guru)\
**Post date:** [November 7, 2019, 4:17pm UTC](https://discuss.appium.io/t/appium-toast-message-not-working-with-uiautomator2-for-android/28510/1 "2019-11-07T16:17:16Z")

</div>

In some Discussions I found that we are able to automate using UIAutomator2. But I tried using the By.xpath("[//android.widget.Toast](https://android.widget.Toast)[1]"), nothing worked . Even I tried to get the Xml Page Source . Even in the Page source not able to get the toast information. Whether Appium supports it . Can anyone please help me. So is there any way to identify the Toast Message in Appium

---

<div class="post-metadata">

**Author:** ![Aleksei](https://discuss.appium.io/user_avatar/discuss.appium.io/aleksei/32/6267_2.png) [@Aleksei](https://discuss.appium.io/u/Aleksei)\
**Post date:** [November 7, 2019, 9:18pm UTC](https://discuss.appium.io/t/appium-toast-message-not-working-with-uiautomator2-for-android/28510/2 "2019-11-07T21:18:44Z")

</div>

UIAutomation2 can’t find toast . It will work only with Espresso.  
Although with some devices it works when we try to find by partial text of toast:

```auto
List<MobileElement> elements = driver
                .findElements(By.xpath("//*[contains(@text,\"" + txt + "\")]"));

```

---

<div class="post-metadata">

**Author:** ![Guru](https://discuss.appium.io/letter_avatar_proxy/v4/letter/g/ecae2f/32.png) [@Guru](https://discuss.appium.io/u/Guru)\
**Post date:** [November 7, 2019, 11:09pm UTC](https://discuss.appium.io/t/appium-toast-message-not-working-with-uiautomator2-for-android/28510/3 "2019-11-07T23:09:25Z")

</div>

Thanks for the reply @Aleksei. I even tried this code ‘List elements = driver  
.findElements(By.xpath("//\*[contains(@text,"" + txt + “”)]"));’ but didn’t work using the UIAutomator2. So I tried using the tess4j OCR to convert the image into text. But am getting the error as below A fatal error has been detected by the Java Runtime Environment:

# 

# SIGILL (0x4) at pc=0x000000012ff2626e, pid=1758, tid=0x0000000000002803

# 

# JRE version: OpenJDK Runtime Environment (8.0\_212-b03) (build 1.8.0\_212-b03)

# Java VM: OpenJDK 64-Bit Server VM (25.212-b03 mixed mode bsd-amd64 compressed oops)

# Problematic frame:

# C [libtesseract.dylib+0x15726e] \_ZNK7ERRCODE5errorEPKc16TessErrorLogCodeS1\_z+0x178

# 

# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try “ulimit -c unlimited” before starting Java again

# 

# An error report file with more information is saved as:

# /Users/nselvam/IdeaProjects/sportsbook/sportsbook-test/hs\_err\_pid1758.log

# 

# If you would like to submit a bug report, please visit:

# [http://bugreport.java.com/bugreport/crash.jsp](http://bugreport.java.com/bugreport/crash.jsp)

# The crash happened outside the Java Virtual Machine in native code.

# See problematic frame for where to report the bug.

# 

Note:  
Am using the Mac OS. Could you suggest the best way to automate the Toast Message . Any help is really appreciated.
