In some Discussions I found that we are able to automate using UIAutomator2. But I tried using the By.xpath("//android.widget.Toast"), 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
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:
List<MobileElement> elements = driver .findElements(By.xpath("//*[contains(@text,\"" + txt + "\")]"));
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)
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:
If you would like to submit a bug report, please visit:
The crash happened outside the Java Virtual Machine in native code.
See problematic frame for where to report the bug.
Am using the Mac OS. Could you suggest the best way to automate the Toast Message . Any help is really appreciated.