WebdriverIO Browserstack -Automating Barcode Scanner
This article will explain how we have automated barcode scanning features using BrowserStack and WebdriverIO iOS App Automation.
By Pravin Kumar — If you automate a mess, you get an automated mess
When we had the barcode scanning feature implemented in our application there was a lot of verification that has to be done manually, which is a very tiring process. Later we found that this can be done via the BrowserStack app automated session.
BrowserStack enables you to test image capture and QR/Bar code scanning from BrowserStack’s mobile device camera. If your mobile app has features, like check scanning, profile image capture, and QR/Bar code scanning, you can use this feature to automate the testing of such a feature in your app.
For the Browserstack to detect barcode correctly, the test data for the barcode should be created such that the barcode image can fit into the scanning area as shown below.
The image can be uploaded using BrowserStack API with the help of the curl command. Supported formats for images are JPG, JPEG, PNG, and the max file size allowed is 10 MB. We can also use custom_id to retrieve the image uploaded and can use it later in the script.
https://gist.github.com/markepvinrap/5ee9e36f9d68516d6aff1d33b4ba2f30#file-upload-shOnce we hit the above curl command we will get the response with the media URL and include custom_id as well.
https://gist.github.com/markepvinrap/d4342e998d27f729b543c113190590e9#file-media-jsonEnabling enableCameraImageInjection: “true” in the desired capabilities ensures your app undergoes Sensor Instrumentation, a process using which BrowserStack supports an app’s interaction with different mobile sensors, such as a Camera or bio metric authentication.
https://gist.github.com/markepvinrap/51ca446066ed550aabdbcef6d8682798#file-caps-jsBy BrowserStack’s custom execute the command with the action cameraImageInjection
as shown in the following code snippets. Ensure the image is injected before the Camera is triggered in the app as the Camera only captures the last injected image.
Now add logic to click the camera button in our mobile application after the uploaded scanner image script. The application will automatically scan the last uploaded image to the BrowserStack cloud.
Author
Editor
We at CaratLane are solving some of the most intriguing challenges to make our mark in the relatively uncharted omnichannel jewellery industry. If you are interested in tackling such obstacles, feel free to drop your updated resume/CV to careers@caratlane.com!
Leave a Reply