<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mark Knapp on Medium]]></title>
        <description><![CDATA[Stories by Mark Knapp on Medium]]></description>
        <link>https://medium.com/@mark-knapp?source=rss-1c8637678f64------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*IXKodyQu_6Ud5Ot8</url>
            <title>Stories by Mark Knapp on Medium</title>
            <link>https://medium.com/@mark-knapp?source=rss-1c8637678f64------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 04:11:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mark-knapp/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Testing Point-of-Sale Devices with Robots and Google Vision]]></title>
            <link>https://medium.com/clover-platform-blog/clover-device-experiences-testing-with-robots-and-google-vision-92a543fdf14a?source=rss-1c8637678f64------2</link>
            <guid isPermaLink="false">https://medium.com/p/92a543fdf14a</guid>
            <category><![CDATA[point-of-sale]]></category>
            <category><![CDATA[robots]]></category>
            <category><![CDATA[qa-automation]]></category>
            <category><![CDATA[google-vision]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Mark Knapp]]></dc:creator>
            <pubDate>Thu, 22 Oct 2020 16:01:09 GMT</pubDate>
            <atom:updated>2020-11-24T19:21:06.269Z</atom:updated>
            <content:encoded><![CDATA[<h3>Testing Point-of-Sale Devices with Robots and Google Vision API</h3><p>During Clover’s exponential growth from launch, we have made steady progress to improve our ratio of automated to manual QA. Clover devices are Android-based, and thus naturally lend themselves to UIAutomator/ADB-based test framework solutions for functional GUI test automation. This test framework has worked well for development and staging environments on non-production devices, but production testing is a different story.</p><figure><img alt="Shelves filled with Clover Mini Point-of-Sale devices for testing." src="https://cdn-images-1.medium.com/max/1024/0*u92cJ38sQtRARRxn" /></figure><h3>Automating the Impossible</h3><p>Clover devices process payments; security is paramount. For security, using Android ADB to access the device OS via USB is disabled. Disabling ADB limits QA on a production device to a true black-box experience. We didn’t need <em>extensive</em> production testing, but we did need <em>some</em> smoke/sanity testing on production devices to confirm that software releases and infra changes rolled out correctly. Quality Engineers manually testing a rollout in the middle of the night is not ideal.</p><p>How does one programmatically control a physical device that has been hardened to prevent programmatic control? The mission was self defeating. Finding a network back-door would mean needing to plug that back-door immediately for security. So we set out to make a true black-box framework. We would build functional GUI test automation that sees only what the screen shows visually and only responds with physical screen touches. This framework would be the only tool we could use to navigate complex application flows to produce very reliable test results.</p><p>We needed a reliable way to make the following three critical actions work:</p><ol><li>See the device’s screen and physically interact with it</li><li>Interpret the screenshots into actionable data</li><li>Use that data to navigate applications, make decisions, and accomplish the test flow</li></ol><p>If any one of these goals could not be achieved to a high standard, the project would fail.</p><h3>Part 1 — Device Interaction</h3><p>For the first part, device interaction, we were lucky that Clover engineers had already broken a lot of ground creating robots to interact with devices. They built these robots for a different sort of testing, but it took minimal effort to repurpose them, such as the one pictured, to our project. The development of these robots is an interesting story in its own right, so I will briefly describe their setup as it is relevant to this project.</p><figure><img alt="A Clover Mini with a robot inserting a card into the back of the device." src="https://cdn-images-1.medium.com/max/1024/0*eAofaDhbDBVIx-46" /></figure><p>We could mount a camera above the device to capture screen displays. The robot arm has a rubber-tipped solenoid that can reliably touch and swipe. In addition, there are robot-controlled arms to run card interactions, like the card insertion pictured above. All the robots in the lab are controlled by a custom web app. Since our robot engineers had already created a decently-sized set of API commands in our web app, our job became easy in this area.</p><h3>Part 2 — Image Interpretation</h3><p>And so we move on to the second part… reliably interpreting camera shots into usable data. Some Clover teams used Tesseract for Optical Character Recognition (OCR), text extraction from images, when needed. Tesseract is free and it performs well on high-contrast documents. However, it does not do as well with unusual or graphical text. These limitations posed a problem; the text on our device screens would be impacted by the device screen resolution and the text would be occasionally embedded in graphical elements.</p><p>We knew that we needed a better solution for our project. The quality of the OCR would be the lynchpin of the test automation. It made sense to give Google Cloud’s <a href="https://cloud.google.com/vision">Vision API</a> a try. In one such test, we used the following still of a camera pointed at a device.</p><figure><img alt="A screen saying “Welcome to Ash” with a red dot below. Underneath “Ash” there are icons for Apple Pay, G Pay and Samsung Pay" src="https://cdn-images-1.medium.com/max/750/0*uUxyU9a9BynArrb5" /></figure><p>The above image was an excellent use case to test Vision API’s capabilities for our project. The camera lens is causing a fish-eye distortion of the edges; the brightness and contrast are a mess; and there is small, close text in different fonts mixed with non-text graphics. We were happy at the results from Vision API:</p><blockquote>SANDBOX Welcome to ASHPAYsh Pay, G Pay, SAMSUNG pay</blockquote><p>It did not have an issue with the red dot in Ash, and it got perfect spelling and capitalization on all the small text. One thing puzzled us… where did “SANDBOX” come from? A glitch in Vision API?</p><p>After a few moments one of us realized it is on a tape label on the device frame in the top left corner, as you can see in the image below, where only the brightness has been increased. Vision API caught the label perfectly despite it being very difficult to spot with the human eye. Combined with Vision API’s easy-to-use API and native Java library, we were sold that this was a good solution.</p><figure><img alt="The same photo with increased brightness to reveal a label on the device edge saying “Sandbox.”" src="https://cdn-images-1.medium.com/max/804/0*HrySz5PCY9vLDbY8" /></figure><p>The native Java library was easy to use, but sparse. So we wrote a wrapper class over it to provide additional functionality. We wanted to parse Vision API’s data for easy usage and logging, search a screen’s text with regular expressions to help with possible OCR flakiness, and employ many helper methods to use various Vision API features in tandem for device screen validation. Of all of Vision API’s features, the ones that were most useful for our purposes were:</p><ul><li>Text OCR for isolated single words</li><li>Document OCR, where text is presented in a hierarchy of <br>body → paragraph → line → word → symbol</li><li>Color palette analysis</li></ul><p>The importance of text OCR can be seen from the example above: we need to know what’s physically being displayed on the screen. Being able to group words into lines with Document OCR proved critical as well. For example, on the device’s main Launcher screen, we may want to click on the “Orders Inspector” app, not the “Orders” app. The next section will show the importance of the color palette analysis feature.</p><h3>Part 3 — Test Framework</h3><p>Finally we get to the third element, the test framework that pulls it all together. For compatibility and ease-of-use, we made the new framework very similar in class structure and style to the existing dev/staging framework for UIAutomator. This allowed a 1-to-1 mapping of production automation tests to dev/stg automation tests; manual tests were already mapped to the dev/stg framework as well. It also allowed for a quick learning curve for SDETs to write new production tests.</p><p>Both frameworks are based on the Page Object Model (POM). Test frameworks that use the POM have a class written for every screen that might appear. The class has methods that govern all the screen’s interactions, like pressing buttons or checking for text. This allows all tests that share screens in their flow to use a single set of code, accelerating test development and maintenance. POM works well for OCR-based testing, since we need to validate every page we see carefully before moving on in the flow. It is one of the aspects of this project that really elevated OCR-scripting to a high-level test framework.</p><p>For efficiency we wanted to minimize our usage of Vision API. The Java library for Vision API returns a data object, List&lt;AnnotatedImageResponse&gt;. We wrote the test framework to use this relatively lightweight data object as its currency. The framework processes a screenshot as infrequently as possible, then passes around the resulting data object to all methods that need to make verifications or decisions.</p><p>The color palette feature in Vision API turned out to be a very useful tool as well. It produces the RGB and the space fraction of the dominant colors. This allowed additional screen/state verification for the test framework. If the device had an all-black screen because it was asleep, using OCR was unreliable because any text fragment picked up by the camera would suggest there was something on the screen. However, no Clover screens are &gt;90% of RGB 0,0,0 (+-15). When the color palette feature gives this result, the automation knows that the robot needs to tap the middle of the screen to wake up the device.</p><figure><img alt="The Clover launcher screen, which is a dark gray with multicolored icons indicating different POS apps." src="https://cdn-images-1.medium.com/max/1024/0*mOERk2eHq9MilZ0e" /></figure><figure><img alt="The customers app, which has a light grey background." src="https://cdn-images-1.medium.com/max/870/0*I2tkZhoBR0hXGx-9" /></figure><p>Another example of color palette in action. Consider the above two screens. The top, darker, screen is the Launcher screen. The bottom, lighter screen is the opening screen to the Customers app. In this scenario, the automation needs to open the Customers app from the Launcher screen. It first verifies that we are on the Launcher screen by checking certain known permanent text fields with OCR and ensuring the color palette is mostly dark gray. It finds the Customers icon text coordinates with OCR and sends a command to the robot to touch the Customers text.</p><p>Now, ideally the app should open to the screen on the bottom. But how can we validate that? OCR will be insufficient because “Customers” is on both screens, and the rest of the text on the Customers app main screen is not reliably there in all device states. This is the kind of situation where the color palette helps. The constructor for the Customers app opening page object validates Customer text, and also validates &gt;70% light gray/white. If the app doesn’t open for some reason, we can fail the test. Color palette is one more tool in making the test automation more reliable.</p><p>Another feature we added to the test framework is watchers. Let me explain watchers by example, using the four screens below. In the first, we are at the Launcher screen. We touch on “Clover Dining” to open that app.</p><figure><img alt="The Clover launch screen" src="https://cdn-images-1.medium.com/max/1024/0*bq9K3ShtMem1e3Yo" /><figcaption>Screen 1</figcaption></figure><p>We are <em>expecting</em> to see Screen 4. But instead we randomly see the screen below. This<em> could</em> cause the whole test to fail.</p><figure><img alt="A page that says “Welcome to Clover Dining. Let’s get started. Agreen button with a white arrow indicates a tutorial" src="https://cdn-images-1.medium.com/max/1024/0*g4anVBoUHyntBsjk" /><figcaption>Screen 2</figcaption></figure><p>Fear not! Our watchers analyze every screenshot we receive. When the second screenshot is received by the framework, a specific watcher written for this state springs into action, and clicks “Let’s get started”. Now we should see Screen 4.</p><figure><img alt="The Dining app is greyed out for a popup that asks the user to first create their floor plan." src="https://cdn-images-1.medium.com/max/1024/0*DFS2UeM75_bgo2Sl" /><figcaption>Screen 3</figcaption></figure><p>Instead, we see Screen 3. Another watcher, triggered recursively by the post-touch screenshot from the previous watcher, handles this one, and touches “I’ll Learn Later”.</p><figure><img alt="The Dining app is now in full view with three tables listed" src="https://cdn-images-1.medium.com/max/1024/0*GqF9kGqFs-2vk745" /><figcaption>Screen 4</figcaption></figure><p>Another screenshot is pulled, Screen 4, and no watchers are matched. The test flow proceeds with its Clover Dining test as if nothing happened.</p><p>In general, watchers are a collection of OCR/color conditions attached to follow-up actions. Every time a screenshot is processed with Vision API, the resulting data object is checked against our library of watchers first. If the conditions of one of the watchers matches the screenshot, that watcher carries out its activities first, generates a new screenshot, then recursively checks watchers again. Once no watchers are triggered, the most recent screenshot’s data object actually goes out to the requesting method.</p><p>Watchers are very useful for intermittent, but expected, pages or artifacts on a screen. These states could derail a test flow and produce a false positive, if not for watchers.</p><p>These test framework features have the added benefit of assisting the robot engineers with their testing. To date, most testing they perform is script-based with fixed-position steps and inflexible test flows. The new framework, with improved OCR, page objects, watchers, and dynamic Java-based flows, has the potential to improve productivity for other robot-based testing.</p><h3>Conclusion</h3><p><strong>Comparing Testing Frameworks</strong></p><p>The table below illustrates what we were able to accomplish with the new test framework. Unexpectedly, the OCR-based tests run twice as fast as the UIAutomater-based tests. This is explained by the UIAutomator-based framework’s frequent pauses to analyze element hierarchy as well as the more in-depth verifications done to the device’s environment that are impossible with OCR. Ultimately OCR and UIA methods accomplish the same goals: automated functional app testing. UIA can test more in-depth, with more tools. OCR is able to test without any sort of internal access to the device, and it does so faster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*GgE-zmt-EfsSNyiYJW1CYQ.png" /></figure><h4><strong>Project Benefits Summary</strong></h4><ul><li>Ability to automate production testing. At scale, allows 10x more test coverage than manual testing in the same time.</li><li>2x test execution speed increase over existing dev automated framework.</li><li>Improved test framework for other robot testing. Potential for improved test reliability and reducing triaging time by engineers.</li><li>Library of OCR/black-box utilities for other Clover applications.</li></ul><p>That concludes the story of our initial device-based black-box automation framework creation. There were many obstacles to overcome to get the small set of smoke tests automated for production.</p><p>We look forward to expanding our test coverage, as well as adding more framework features like machine learning. We hope to use Google Cloud AutoML to recognize various non-textual symbols, like the hamburger menu icon, the refresh/sync icon, and the lock icon. AutoML could also increase our page validation even further if we train it to recognize certain screens, disregarding expected variations.</p><p>My name is Mark Knapp. I have been with Clover since 2017 and working in the Silicon Valley in various software engineering roles since 2001. I am currently a senior staff engineer on Clover’s Tools and Technologies team. The TNT team focuses on technical solutions to improve Clover developer and QA productivity. This is often test automation frameworks, but also includes CI solutions, custom device management apps, emulators, performance and more. Since Clover develops a truly full-stack product, with custom hardware, firmware/OS, apps, servers, payments, etc, there is a lot of variety in the problems our team tries to solve. Clover is hiring: <a href="https://careers.clover.com/">https://careers.clover.com/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92a543fdf14a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/clover-platform-blog/clover-device-experiences-testing-with-robots-and-google-vision-92a543fdf14a">Testing Point-of-Sale Devices with Robots and Google Vision</a> was originally published in <a href="https://medium.com/clover-platform-blog">Clover Platform Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>