Instead of checking and putting all energy just for sake of toast messages, the same we can easily cover using espresso at Unit/Integration test level. I believe that is better approach, We need to focus on critical functionality that really need to be automated instead of such trivial use cases. That way we can better categorize test cases also implement better test practices to our work.
For who using Python, Can do that with the help of pyautogui Library this is piece of code that’s help
toaster_image = toaster image file path
screenshot_image = screenshot image file path [ taken by Appium ]
from pyautogui import locate
class ClassName:
def compareImage (self, toaster_image, screenshot_image):
result = locate(str(toaster_image), str(screenshot_image))
if result is None:
return False
else:
return True
Hello
I have try the above link and created the example with tess4j 3.2.1. when i execute the example it take the screenshot and convert the image to text but not the toast message of the image .please help me out ?
Below is image and output result:
1
Can you please the detailed video where the dll placing is also defined? this video has a very limited understanding but didn’t worked when i tried this
Appium Directly does not give any API to read toast message we need to do it using tess4j jar. First we need to take screen shot and then we need to read the text from screen shot using tess4j API.
SimpleDateFormat dateFormat = new SimpleDateFormat(“dd-MMM-yyyy__hh_mm_ssaa”);
new File(scrShotDir).mkdirs(); // Create folder under project with name
// “screenshots” if doesn’t exist
destFile = dateFormat.format(new Date()) + “.png”; // Set file name
// using current
// date time.
try {
FileUtils.copyFile(scrFile, new File(scrShotDir + “/” + destFile)); // Copy
// paste
// file
// at
// destination
// folder
// location
} catch (IOException e) {
System.out.println(“Image not transfered to screenshot folder”);
e.printStackTrace();
}
return destFile;
}