Well, for app’s functional testing you want to cover both. But if the core goal is to test the code scanning functionality, then whichever is easier (likely #1) will do, since it technically works the same internally I would assume, just the source data originated differently, but the type of data is essentially same.
I would try tackling #1 first since that should work with simulator and device, if the app offers scanning off an image on the device.
Try tackle #2, once you got #1 working. For #2, I’d have a test setup with printed codes on paper, cardboard, etc. to test against like being at a store, etc. and manually swap the hardcopy images. But I’d also have a soft copy image setup where the bar/QR codes come from a digital display (monitor, TV, digital picture frame, etc.) positioned in front of the device camera and the device camera scans off the digital display. This latter setup would then be automatable and can programmatically swap source images in the digital display.
As for specifics on automating this with Appiums, others can help you. I haven’t touched Appium much to give guidance code/setup wise.
In Android, I have tried one workaround to resolve this but you cannot say it as an Automation testing because it needs manual intervention.
Also it can only be implemented using physical device not with emulator. Approach:
Take QR code in a file in PC (say .PNG image)
Click scan button using appium.
Point you device camera to QR code and let it focus to scan.
(Synchronize the process with correct time outs)
But, if any feasible solution can be implemented then let me know.
Haven’t tried this solution as we were stopping the suite just before scanning, so I can’t vouch for it but inside of my mind I was looking for something like this, so full credit to @Aleksei for this. It’s not SO other then that I’d mark it as ‘Solved’.
It would be good to know if some one tried this solution successfully.
Aleksei Can you help me with this. I always get Invalid device: " "
what are you passing in the string cmd after addphoto, I passed my real device UDID… I am running this on real device
I have a scenario where I have to capture the image of a check to send it as an input to scanning API. I need to automate it. I need to capture front and back of the check. Can anyone help me with the way to do it? Following are the steps:
Tap on the camera icon
Capture the image of front of check
Tap on the camera icon for capturing back of the check
Hi Guys,
I want to automate reading barcode with phone camera. Daily we get around 100 voachars to read. We need to read this voachars in iPhone, any idea how to automate.
I would try to work with application developers on this. They could hardcode a special place in application documents, where the automation script would upload specially prepared images to recognize.
Hi @mykola-mokhnach. Any update or roadmap on the scanning related automation. So many projects especially in postal, e-commerce have camera based scanning and it is becoming more significant for automating those areas also
I am trying to automate a QR code using a real device and used the following code, but i get Invalid UDUD error
public void addPhoto() {
//xcrun instruments -s device = list all simulators
//xcrun simctl addphoto C2C451F0-9D33-4872-8615-4DE41D1A1017 /Users/Aleksei/Documents/test2.png
try {
String[] cmd = {“xcrun”, “simctl”, “addphoto”, “C2C451F0-9D33-4872-8615-4DE41D1A1017”, “/Users/Aleksei/Downloads/userPhoto.png”};
Process process = Runtime.getRuntime().exec(cmd);
BufferedReader bufferedReader = new BufferedReader(new
InputStreamReader(process.getErrorStream()));