<?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[Test Automation University - Medium]]></title>
        <description><![CDATA[TAU is a community of technical professionals — including testers, engineers and developers — brought together to build, identify, aggregate, and amplify best practices in test automation strategies and techniques. - Medium]]></description>
        <link>https://medium.com/test-automation-university?source=rss----27be6f655b45---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Test Automation University - Medium</title>
            <link>https://medium.com/test-automation-university?source=rss----27be6f655b45---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 02:09:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/test-automation-university" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to manage your python virtualenvs with Pipenv]]></title>
            <link>https://medium.com/test-automation-university/how-to-manage-your-python-virtualenvs-with-pipenv-f1220ded702e?source=rss----27be6f655b45---4</link>
            <guid isPermaLink="false">https://medium.com/p/f1220ded702e</guid>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[virtualenv]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[pipenv]]></category>
            <dc:creator><![CDATA[Gaurav Singh]]></dc:creator>
            <pubDate>Thu, 23 Jul 2020 17:19:53 GMT</pubDate>
            <atom:updated>2020-08-29T02:54:55.694Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jAp7cl37l5JEuPua" /></figure><p>If you are already aware of what <a href="https://virtualenv.pypa.io/en/stable/"><strong>virtualenv</strong></a>, <a href="https://virtualenvwrapper.readthedocs.io/en/latest/"><strong>virtualenvwrapper</strong></a> and is in the python ecosystem and have also heard or used and are just grepping for the commands to use to quickly set up and run an environment, then just refer to below:</p><p><strong>TL;DR 😉</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/673931cf6457b2740587ad7d44c13cc7/href">https://medium.com/media/673931cf6457b2740587ad7d44c13cc7/href</a></iframe><p>If you thinking something along the lines of</p><blockquote><em>I am aware of how to use </em><strong><em>requirements.txt </em></strong><em>file in python and have used virtualenvs previously, it works fine for my needs, frankly what is this pipenv module and why should I care? 🤷🏻‍♂️</em></blockquote><p>Then do read on further for a bit of a long winding story 🍷</p><h3>First, A bit of context 🤓</h3><p>In python, the packaging story has had lots of options. Just take a look <a href="https://packaging.python.org/guides/tool-recommendations/">here</a> if you want to understand what all options are available.</p><p>A tried and tested approach to quickly create a reproducible env for you app has been to use <strong>virtualenv </strong>module and install all the modules required using <strong>pip </strong>and then capture them with pinned dependencies versions using <strong>requirements.txt</strong></p><p>Below is a sample requirements.txt file with pinned dependencies</p><pre>certifi==2020.6.20<br>chardet==3.0.4<br>idna==2.10<br>requests==2.24.0<br>urllib3==1.25.9</pre><h3>Why do we need virtualenvs? Can’t I just install the modules on my base python installation?</h3><p>This is a beginner question that every person new to Python and its ecosystem asks.</p><p>Well, The short answer is you can absolutely do that. However, it’s not the recommended option.</p><p>Why? You might ask, Let me give you an example.</p><p>Let’s say I use <strong>Python 3.8</strong> for my personal projects and want to use requests module version of 1.2.0.</p><p>But at work, we as a team have still have not shifted to the latest version and are using <strong>Python 3.5 </strong>with another version of requests = 1.0.2 (example)</p><p>Supporting this workflow is possible by creating two different <strong>virtualenvs</strong> with different python versions and I can quickly activate the required environment for use. It’s also quite trivial to destroy this environment and rebuild it again in case the environment is polluted or some dependency is breaking your app.</p><blockquote><em>💡 </em><strong><em>Pro Tip:</em></strong><em> Please </em><strong><em>DO NOT</em></strong><em> install modules in your base python version (installed/pre-installed via the OS). You might accidentally update the version of a dependency which might break something in your system/project. </em><strong><em>Always use virtualenvs.</em></strong><em> 🙏🏻</em></blockquote><p>Also, There are already <a href="https://virtualenv.pypa.io/en/stable/#useful-links">abstractions built over <strong>virtualenv</strong></a><strong> </strong>such as <strong>virtualenvwrapper </strong>and <strong>tox </strong>that make it a bit more convenient to use the <strong>venv </strong>(module for virtualenv). Diving into how they work is probably a story for another time. 🤔</p><h3>A new hope ☀️</h3><p><strong>Pipenv</strong> is the new solution to this packaging story and it wraps over pip, virtualenv, and provides a lot of virtualenvwrapper like capabilities while makes it super convenient to set up dependencies for your project.</p><p>It is written by <a href="https://github.com/kennethreitz">Kenneth Reitz</a> of <strong>requests</strong> module fame and is actively maintained by the Python community. This tool has very quickly risen to become the recommended tool for Application dependency management by python. This is a higher-level tool than pip and can make it very easy for multiple contributors to work/manage dependencies in a large project</p><p>Let’s see how to install, setup, and create a virtualenv for a project all via pipenv. We would use terminal commands and see how to work with pipenv. However, if you are using an editor like Pycharm, we will also see how to set it up there.</p><h3>Installation 🖥</h3><p>To install pipenv, you can use homebrew on Mac/Linux</p><pre>brew install pipenv</pre><p>Or, Alternatively, You can also use pip directly with a <a href="https://pip.pypa.io/en/stable/user_guide/#user-installs">user installation</a> to install pipenv</p><pre>pip install --user pipenv</pre><h3>Pre-requisites</h3><p>If you work with multiple python projects on your machine, it is a good practice to store the virtualenvs in a central directory which you can easily refer to later on.</p><p>To enable that, we need to add an environment variable WORKON_HOME in a shell configuration file of your choice (.zshrc, or .bash_profile)</p><blockquote><em>ℹ️ In the absence of WORKON_HOME variable being set, pipenv would simply create the virtualenv in the current terminal dir</em></blockquote><pre>export WORKON_HOME=~/virtualenvs<br>export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3<br>export LANG=en_US.UTF-8<br>export LC_ALL=en_US.UTF-8</pre><h3>Create a project and virtualenv</h3><p>Go to the project for which you want to create a virtualenv for, and then execute below command</p><pre>cd test_project <br>pipenv --three</pre><p>Executing the above command would give an output like below, notice it <strong>creates a virtualenv</strong> in <strong>WORKON_HOME</strong> directory with the name of the project followed by a string. ( test_project-UdkZ3s0t)</p><pre>Creating a virtualenv for this project…<br>Pipfile: /Users/gaurav/test_project/Pipfile<br>Using /usr/local/opt/python@3.8/bin/python3.8 (3.8.3) to create virtualenv…<br>⠇ Creating virtual environment...created virtual environment CPython3.8.3.final.0-64 in 464ms<br>  creator CPython3Posix(dest=/Users/gaurav/virtualenvs/test_project-UdkZ3s0t, clear=False, global=False)<br>  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/gaurav/Library/Application Support/virtualenv)<br>    added seed packages: pip==20.1.1, setuptools==47.3.1, wheel==0.34.2<br>  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator<br> <br>✔ Successfully created virtual environment!<br>Virtualenv location: /Users/gaurav/virtualenvs/test_project-UdkZ3s0</pre><h3>Activate the environment</h3><p>To open a shell with the already created virtualenv</p><pre>pipenv shell</pre><p>You would see something like below:</p><pre>Launching subshell in virtual environment…<br> . /Users/gaurav/virtualenvs/test_project-UdkZ3s0t/bin/activate<br>➜  test_project  . /Users/gaurav/virtualenvs/test_project-UdkZ3s0t/bin/activate<br>(test_project) ➜  test_project</pre><p>Notice that pipenv is invoking <strong>/bin/activate</strong> inside our created virtualenv just as you manually would if you were not using a higher-level tool like virtualenvwrapper</p><h3>Installing package</h3><p>To install any module in this newly created environment, type the module name from <a href="https://pypi.org/">PyPi</a>.</p><p>Below, we are installing requests module</p><pre>pipenv install requests</pre><p>The above command outputs below.</p><pre>Installing requests…<br>Adding requests to Pipfile&#39;s [packages]…<br>✔ Installation Succeeded<br>Pipfile.lock not found, creating…<br>Locking [dev-packages] dependencies…<br>Locking [packages] dependencies…<br>Building requirements...<br>Resolving dependencies...<br>✔ Success!<br>Updated Pipfile.lock (fbd99e)!<br>Installing dependencies from Pipfile.lock (fbd99e)…<br>  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00</pre><p>Couple of things to note:</p><ol><li><strong>pipenv</strong> creates a Pipfile.lock file (if it does not exist already)</li><li>Once the module is installed it updates Pipfile.lock file</li><li>Finally using the lock file it installs the dependencies</li></ol><h3>The Pipfile</h3><p>Pipenv creates a Pipfile to keep all the required information about your dependencies. Let&#39;s inspect its contents</p><pre>[source]<br>name = &quot;pypi&quot;<br>url = &quot;<a href="https://pypi.org/simple">https://pypi.org/simple</a>&quot;<br>verify_ssl = true<br> <br>[dev-packages]<br> <br>[packages]<br>requests = &quot;*&quot;<br> <br>[requires]<br>python_version = &quot;3.8&quot;</pre><p>Pipfile mentions the version of python required by this project under [requires] and has also specified requests = &quot;*&quot; under [packages], notice, the * the wildcard means we don&#39;t care about a specific version of requests as long as the latest version is installed.</p><p>This is different from pinning the dependency to a specific version like: requests = 2.24.0 and offers more flexibility since pipenv would figure out the dependency graph and ensure that all the required dependencies of requests modules are automatically updated.</p><blockquote><em>💡 For the people from the JVM world, a parallel can be drawn to </em><em>build.gradle or </em><em>pom.xml files wherein we specify which repository to pick the library from, the packages to import and the language version to use</em></blockquote><h3>Pipfile.lock</h3><p>In addition to Pipfile, pipenv creates a Pipfile.lock as well which has finer level details about the specific version of packages that are installed in the virtualenv.</p><p>Notice, any changes made manually to this can be overwritten if you update pipfile (with some new package) and then run pipenv update</p><p>If you check the content of Pipfile.lock, you can notice that it maintains the version of the module and its <strong>direct</strong>, <strong>transitive dependencies</strong>, This ensures pipenv is able to reproduce the exact runtime environment every time</p><pre>{<br>    &quot;_meta&quot;: {<br>        &quot;hash&quot;: {<br>            &quot;sha256&quot;: &quot;acbc8c4e7f2f98f1059b2a93d581ef43f4aa0c9741e64e6253adff8e35fbd99e&quot;<br>        },<br>        &quot;pipfile-spec&quot;: 6,<br>        &quot;requires&quot;: {<br>            &quot;python_version&quot;: &quot;3.8&quot;<br>        },<br>        &quot;sources&quot;: [<br>            {<br>                &quot;name&quot;: &quot;pypi&quot;,<br>                &quot;url&quot;: &quot;<a href="https://pypi.org/simple">https://pypi.org/simple</a>&quot;,<br>                &quot;verify_ssl&quot;: true<br>            }<br>        ]<br>    },<br>    &quot;default&quot;: {<br>        ....<br>        &quot;requests&quot;: {<br>            &quot;hashes&quot;: [<br>                &quot;sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b&quot;,<br>                &quot;sha256:fe75cc94a9443b9246fc7049224f75604b113c36acb93f87b80ed42c44cbb898&quot;<br>            ],<br>            &quot;index&quot;: &quot;pypi&quot;,<br>            &quot;version&quot;: &quot;==2.24.0&quot;<br>        },<br>        &quot;urllib3&quot;: {<br>            &quot;hashes&quot;: [<br>                &quot;sha256:3018294ebefce6572a474f0604c2021e33b3fd8006ecd11d62107a5d2a963527&quot;,<br>                &quot;sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115&quot;<br>            ],<br>            &quot;markers&quot;: &quot;python_version &gt;= &#39;2.7&#39; and python_version not in &#39;3.0, 3.1, 3.2, 3.3, 3.4&#39; and python_version &lt; &#39;4&#39;&quot;,<br>            &quot;version&quot;: &quot;==1.25.9&quot;<br>        }<br>    },<br>    &quot;develop&quot;: {}<br>}</pre><h3>Compatibility with requirements.txt</h3><p>If you use requirements.txt file extensively with your project. You can easily generate a file using pipenv.</p><pre>pipenv lock -r &gt; requirements.txt</pre><blockquote><em>Also, if your project already has a requirements.txt file then while doing </em><em>pipenv install, pipenv would automatically pick it up and install the required packages.</em></blockquote><h3>Tearing down a virtualenv</h3><p>Removing a virtualenv is as simple as executing pipenv --rm</p><pre>(test_project) ➜  test_project pipenv --rm<br>Removing virtualenv (/Users/gaurav/virtualenvs/test_project-UdkZ3s0t)…</pre><h3>Setting up a virtualenv using Pycharm editor</h3><p>Pycharm provides a convenient way to use/and create a pipenv</p><h3>Select an env</h3><ol><li>Open settings</li><li>Go to project interpreter</li><li>If you have a pipenv that you want to share across multiple projects then select it from the drop-down</li><li>Else, Tap on the ... button on the top right and click on <strong>Add new</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7O-KEpGmfzQ2MWlq" /></figure><h3>Create a pipenv</h3><p>If you want to create a fresh env then click on the Pipenv environment and select the base interpreter as the desired version to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UHUREAgX0fPzC_LQ" /></figure><h3>Select an existing env</h3><p>Alternatively, If you have already created a <strong>pipenv</strong> via command line, then you can select it by clicking on <strong>Virtualenv environment</strong> and under <strong>Existing environment</strong>, navigating till the path where your virtualenv resides and select /bin/python</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*taYj70EaSVKc5MVt" /></figure><h3>Conclusion</h3><p>Pipenv is a <strong>really</strong> powerful tool that makes working with virtualenvs and dependencies a breeze. If you have not yet tried it out, I would highly recommend you check it out.</p><p>If you found this post useful, Do share it with a friend or colleague. Until next time. Happy coding.</p><h3>Further References</h3><ul><li><a href="https://packaging.python.org/tutorials/managing-dependencies/">Managing application dependencies</a> on python.org</li><li><a href="https://pipenv.pypa.io/en/latest/">Pipenv docs</a></li></ul><p>Gaurav Singh is an <a href="https://info.applitools.com/uFGB">instructor</a> at <a href="https://info.applitools.com/uwi7">Test Automation University</a>.</p><p><em>Test Automation University is sponsored by </em><a href="https://info.applitools.com/uw9e"><em>Applitools</em></a><em>.</em></p><p><em>Originally published at </em><a href="https://automationhacks.io/2020/07/12/how-to-manage-your-python-virtualenvs-with-pipenv/"><em>https://automationhacks.io</em></a><em> on July 12, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1220ded702e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/test-automation-university/how-to-manage-your-python-virtualenvs-with-pipenv-f1220ded702e">How to manage your python virtualenvs with Pipenv</a> was originally published in <a href="https://medium.com/test-automation-university">Test Automation University</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Do I Test Visually With Python?]]></title>
            <link>https://medium.com/test-automation-university/how-do-i-test-visually-with-python-d28e56c97c81?source=rss----27be6f655b45---4</link>
            <guid isPermaLink="false">https://medium.com/p/d28e56c97c81</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Michael Battat]]></dc:creator>
            <pubDate>Tue, 14 Jul 2020 16:47:41 GMT</pubDate>
            <atom:updated>2020-07-14T16:47:41.491Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0QrFLK9M86NeO-SU.png" /></figure><p><strong>How Do I Test Visually With Python?</strong></p><p><strong>Python has gained popularity as a language for writing tests because of its scalability, structural flexibility, and rich library for testing. Because of its flexibility, Python offers a broad ability to automate testing from unit tests up to end-to-end testing. And, Applitools integrates with Python to add visual testing easily into Python-based end-to-end tests.</strong></p><p>I finished taking <a href="https://www.linkedin.com/in/automationhacks/">Gaurav Singh’s</a> course, <a href="https://testautomationu.applitools.com/visual-testing-python/">Automated Visual Testing with Python</a>, on <a href="https://info.applitools.com/uwi7">Test Automation University</a>. And, I passed. But, before I show you my certificate of completion, I want to give you a quick review of Gaurav’s course.</p><h3>About The Instructor</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MiolPdUIcmwzrLhm.jpeg" /></figure><p>Gaurav Singh advocates for test automation as part of his job. Gaurav serves as a test automation lead at Gojek, a logistics company based in Southeast Asia. In addition to Python (the subject of this course), Gaurav programs in Kotlin and Java.</p><p>He writes extensively about test automation. Some of his blog posts include:</p><h3>Why Python?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wZ4WzUfCVKcAC5ry.png" /></figure><p>Python provides huge value for testing, according to the <a href="https://automationpanda.com/">Automation Panda</a>blogger, Andrew Knight. <a href="https://automationpanda.com/2018/07/26/why-python-is-great-for-test-automation/">He writes</a>:</p><p>“Python is object-oriented and functional. It lets programmers decide if functions or classes are better for the needs at hand. This is a major boon for test automation because (a) stateless functions avoid side effects and (b) simple syntax for those functions make them readable. pytest itself uses functions for test cases instead of shoehorning them into classes (à la JUnit).”</p><p>Some people think that interpreted code suffers performance issues, but Andrew points out that the performance suits testing — which can wait milliseconds to seconds for tests to complete. And, the flexibility you get from choosing Python provides huge advantages to test development.</p><h3>Prerequisites</h3><p>You need to know Python to take Gaurav’s course, because he does not teach the language or teach you how to use it for test purposes. If you know Python but have never used it for testing, Gaurav points you to <a href="https://www.linkedin.com/in/jessingrassellino/">Jess Ingrasselino Ed.D.’s</a> excellent course on Test Automation University, <a href="https://info.applitools.com/uGbM">Python for Test Automation</a>.</p><p>You will need Python 3. By default, Macs come with Python 2 installed, so you will need to install Python 3. Gaurav gives you instructions for doing this.</p><p>You also need an IDE. Gaurav demonstrates using PyCharm for his IDE — you can download it pretty easily. Again — good instructions. You can also choose another IDE — Virtual Studio Code, for example. But the examples all work with PyCharm.</p><h3>Course Structure</h3><p>This course has an introduction and 11 chapters. Each of the 11 chapters includes a quiz. You need to take and succeed with the quizzes to pass the course and get the course certificate.</p><p>The 11 chapters include:</p><ul><li>1 — Introduction to Visual Testing</li><li>2 — Setting Up Dependencies</li><li>3 — Getting the API Key</li><li>4 — Setup PyCharm and Initializing Applitools Eyes</li><li>5 — Running Your First Test</li><li>6 — Understanding Match Levels</li><li>7 — Checkpoints</li><li>8 — Organizing Tests</li><li>9 — Visual Validation of PDF Files</li><li>10 — Analyzing Test Results</li><li>11 — Integrations</li></ul><h3>Getting Going</h3><p>The first three steps are the parts to get organized. In Chapter 1, Gaurav brings up some concepts around visual testing — why it’s important. He shows some examples of pages that cause some percentage of users to abandon an app. For instance, if the button that drives customers to buy your product gets covered with text. The button may still function, but what percentage of your customers pause when they see this kind of error? And, the bummer is that your existing test automation cannot catch this kind of error. The button may be findable and clickable for your test automation — so your tests will continue to pass.</p><p>In Chapter 2, Gaurav gives you instructions for installing all the python test software. If you’re experienced with Python, you will find these instructions straightforward. If not, you might encounter differences between your environment and his. Gaurav points to a couple of sites to help you install Python3. I did, but ran into some issues with my environment on my Mac. I gave up and moved to Linux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DtfdsEH-SQo8cSdr.jpg" /></figure><p>Also in Chapter 2, Gaurav gets you to install the Eyes Selenium software for Python. This lets you call on Applitools Eyes calls in your Python code. Gaurav leaves the explanation for this code to later chapters.</p><p>Next, he makes sure you can run Applitools Eyes by getting sure you sign up for a free account in Chapter 3. To run Applitools, you need an API key, which you can get once you have an account.</p><p>Finally, he makes sure your PyCharm IDE can work with Applitools Eyes by giving you some initial coding steps to initialize Applitools and ensure the Applitools API Key gets loaded.</p><h3>Running Visual Tests with Python</h3><p>Next, Gaurav runs through some tests demonstrating calls to Applitools Eyes once you have navigated to a given page.</p><p>In Chapter 5, Gaurav shows how Applitools Eyes can validate the output of a given functional task. He uses a bookstore app that Angie Jones developed to demonstrate the limits of code-based assertions.</p><p>Gaurav shows how to build a test for the app in Python. He shows how to exercise the app with Python, and how to call Applitools to check the page. By using a search function that presents a single result, he captures the resulting page image as a baseline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BseaVARTxj8XxAj9.png" /></figure><p>Gaurav then introduces a visual difference. He changes the color of the pricing box in the CSS for the app. The text is correct, but the visual image differs. He shows that Applitools catches the difference, which a text assertion might catch if a tester coded for the CSS change.</p><p>In Chapter 6, Gaurav digs into match levels in Applitools:</p><ul><li>Exact — pixel comparison</li><li>Strict (the default) — using AI to inspect for visually-meaningful differences</li><li>Content — checking for content and ignoring color differences</li><li>Layout — handling dynamic content (like news) and ensuring that the page structure and layout remain consistent</li></ul><p>Gaurav explains why each match level matters. Basically, no one uses Exact in production — it just demonstrates how many more errors your typical pixel checker uncovers that don’t matter to a user. Layout and Content have specific purposes. Most of the time, use Strict.</p><p>In Chapter 7, Gaurav goes through some of the special capabilities in Applitools. For instance, if an app page extends beyond the viewport, you can configure Applitools to capture an entire page. Applitools will scroll through and capture the entire page to its horizontal and vertical maximum size for comparison purposes. You can also capture specific regions, or regions-by-element, and run different comparisons on those regions. You can even capture a region inside an iFrame.</p><h3>Becoming Productive with Visual Validation in Python</h3><p>The rest of the course focuses on how you can become productive using Applitools for visual testing with Python.</p><p>Chapter 8 focuses on how to organize tests into batches for test suites. You can capture multiple tests on a single page and see how the behavior compares for that page. When users have multiple functions to exercise on a single page, they find really powerful to group all the tests for a single page together.</p><p>Chapter 9 explains how you can use the Applitools Image Tester application to validate PDF files. How do you test the PDF output of your applications? Applitools gives you a stand-alone app to make those comparisons. The Image Tester application can compare two image files — including PDF files — and give you a comparison. While Image Tester is a .jar and runs in Java, you can direct Selenium to call Image Tester from inside your Selenium Python tests. You can use the Applitools controls to run strict, content, or layout comparisons of your PDFs — and you can choose to ignore regions you know will differ (like, say, a timestamp).</p><p>Chapter 10 dives into the ways you can analyze test results. Chapter 11 focuses on integrations. Both chapters help you understand how to get the most out of using Applitools with your development and test infrastructure.</p><p>As always, I include my certificate of completion:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mZ9oUGB7C44_S7D7h78wGA.png" /></figure><h3>Conclusion</h3><p>Gaurav’s course just focuses on using Applitools with Python. While he covers a bit of good test writing style, he wants to show you how to use Applitools. If you already know Applitools, this course provides a great refresher on the basic capabilities, and you will get some idea of the power of adding Applitools to your existing tests written in Python.</p><h3>Next Steps</h3><p>I’d recommend taking Raja Rao’s course on <a href="https://info.applitools.com/uw9u">Modernizing Functional Test Automation Through Visual AI</a>. While the course focuses on Java, its principles help explain how to cut down on coded assertions in your end-to-end tests and use the Visual AI in Applitools to validate your application output.</p><p><a href="https://info.applitools.com/uw9g">Sign up for a free Applitools account</a>.</p><p><a href="https://info.applitools.com/uw9h">Request an Applitools demo</a>.</p><p><em>Originally published at </em><a href="https://info.applitools.com/uGbJ"><em>https://applitools.com</em></a><em> on June 30, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d28e56c97c81" width="1" height="1" alt=""><hr><p><a href="https://medium.com/test-automation-university/how-do-i-test-visually-with-python-d28e56c97c81">How Do I Test Visually With Python?</a> was originally published in <a href="https://medium.com/test-automation-university">Test Automation University</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using adb and cmdline to ease android app testing]]></title>
            <link>https://medium.com/test-automation-university/using-adb-and-cmdline-to-ease-android-app-testing-19f64340dae7?source=rss----27be6f655b45---4</link>
            <guid isPermaLink="false">https://medium.com/p/19f64340dae7</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[tools-and-tactics]]></category>
            <category><![CDATA[adb]]></category>
            <category><![CDATA[mobile-testing]]></category>
            <category><![CDATA[test-automation]]></category>
            <dc:creator><![CDATA[Gaurav Singh]]></dc:creator>
            <pubDate>Tue, 23 Jun 2020 09:54:43 GMT</pubDate>
            <atom:updated>2020-09-02T12:23:53.856Z</atom:updated>
            <content:encoded><![CDATA[<h3>Using adb and cmdline to ease Android app testing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iIpk4nqcCSYp-AXO" /></figure><p>Hello there,</p><p>If you have been testing mobile apps on the android platform, chances are there are some common workflows/steps that you follow to enable you to test effectively.</p><p>Most of these are done as you get set up or are in the middle of actually testing the feature/functionality on the app.</p><p>Some of these include:</p><ul><li>Copy the apk file over to the real device using <strong>Android File Transfer</strong> (on mac) while ensuring that the MTP mode is enabled for file transfer in the first place</li><li>Installing the build by finding it in the <strong>sdcard</strong> folder</li><li>Capture any crash logs that occur while you are testing the app</li><li>If you notice a bug, then take a screenshot</li><li>While pairing with another dev/tester, require to share the real device screen, (You might be using <strong>Vysor</strong> for this but the loss of quality in the free version is simply annoying)</li><li>Take videos of the test execution cycle.</li></ul><p>Now, some or most of these flows can be performed via <strong>Android studio</strong> by using the logcat control, however, the caveat is that Android Studio/running emulator is quite a performance intensive task and captures a lot of memory</p><p>If you are running other demanding applications like IntelliJ, Pycharm, and possibly Docker then it can quickly slow down your machine considerably and bring you close to the point of frustration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*opddyCzlRoTBTO6X" /></figure><p>Well, we don’t want that to happen to us, do we?</p><p>As testers, we owe it to ourselves to solve some of these pains or to make it easy. Turns out after a little bit of digging and some pointers from friendly android devs in my current team, I was able to figure out some easy workarounds to accomplish all these tasks <em>All via command line and adb… </em>👨🏻‍💻</p><p>Sweet. Let&#39;s get started.</p><h3>Pre-requisite</h3><blockquote><em>Most of the commands in this section requires </em><strong><em>adb</em></strong><em> to be setup and </em><strong><em>available in your path</em></strong><em>.</em></blockquote><blockquote><em>Also ensure the device has </em><strong><em>USB debugging</em></strong><em> enabled in </em><strong><em>Developer Options</em></strong></blockquote><h3>Open emulator via adb</h3><p>What if you wanted to open an emulator directly via the command line? A way to do this is to go to AVD manager in android studio and then click on the play for the relevant emulator image you want to start.</p><p>However, this could just as easily be done via CMD line using emulator with -avd option</p><p>If you are on other platforms like Windows/Linux, then find the directory where the Android/sdk/emulator is present and replace that in the below command.</p><pre>Library/Android/sdk/emulator/emulator -avd &lt;emulator_image_name&gt; -netdelay none -netspeed full</pre><h3>How to copy a file over to you device</h3><p>Assuming you have a single android device connected via USB, You can execute the below command, this would copy <strong>any file</strong> from your local dir to a connected emulator or real device.</p><p>Huge time saver ⏰ and very quick compared to manually dragging the file over using the Android File Transfer mac app.</p><pre>adb push &lt;file&gt; /sdcard/</pre><p>However, If you have multiple emulators/devices connected on executing above command you would get an error like below:</p><pre>adb: error: failed to get feature set: more than one device/emulator</pre><p>To workaround, We need to tell adb, which device we want to send the file over to.</p><p>First, we need to know what devices are connected. Execute below</p><pre>adb devices -l</pre><p>This would return a list of connected devices. Notice adb provides a unique string for all real devices ( 5200d275428186b3) and for all the running emulators ( emulator-&lt;TCP_PORT&gt;)</p><pre>List of devices attached 5200d275428186b3 device usb:342097920X product:m30ltedd model:SM_M305F device:m30lte transport_id:1 emulator-5554 device product:sdk_gphone_x86_arm model:AOSP_on_IA_Emulator device:generic_x86_arm transport_id:2</pre><p>Cool, so to transfer the file over, we need to tell adb to use the device that we are interested in with the -s option and the remaining command remains the same.</p><pre>adb -s &lt;emulator_or_real_device_id&gt; push &lt;file&gt; /sdcard/</pre><h3>Installing APK via adb</h3><p>Given that you have the APK file in a dir on your local machine, you can use install the command in adb to directly stream the file over and install on the device</p><pre>adb -s &lt;emulator_or_real_device_id&gt; install &lt;file_name&gt;.apk</pre><p>Simple and sweet! 🙌🏼</p><h3>Uninstalling the previously installed app</h3><p>Running the above command would install the app every time, but if you wanted to do a clean install and ensure the app is not already installed (Simulate a first-time users experience)</p><p>Then we can easily uninstall the app via pm (package manager) command</p><p>You would first need to know the package name for the app that you want to uninstall, Run below</p><pre>adb -s &lt;emulator_or_real_device_id&gt; shell dumpsys window windows | grep -i &quot;mCurrentFocus&quot;</pre><p>This would give an output like below:</p><pre>mCurrentFocus=Window{253d2d3 u0 com.example.app.staging/com.example.app.RootActivity}</pre><p>Here the package name would be com.example.app.staging</p><p>To uninstall, we can run below command:</p><pre>adb -s &lt;emulator_or_real_device_id&gt; shell pm uninstall &lt;package_name&gt;</pre><p>So, now we know how to copy a file over, and also install an app on any device (real or emulated).</p><h3>Testing the app</h3><p>Given we are testing the application, the 3 main tasks that we need to perform are:</p><ul><li>Take a screenshot</li><li>Record a movie</li><li>Capture crash logs</li><li>Share the real device screen on your system (during a pairing session)</li></ul><h3>Capturing a screenshot</h3><p>Let&#39;s say, I have the Fake GPS on the real device screen and I noticed a bug, I would want to share this with the devs in the bug report</p><p>We can use screencap utility to capture and store the screenshot</p><p>To directly take the screenshot and copy to your local machine execute below:</p><pre>adb exec-out screencap -p &gt; &lt;file_name&gt;.png</pre><h3>Recording a video:</h3><p>To record a video we can use screenrecord command with adb</p><p>Firstly open adb shell</p><p>Then execute below to start recording</p><pre>screenrecord --verbose /sdcard/demo.mp4</pre><p>Finally when you are done, Press Control + C to exit</p><p>and finally, copy the file to your local machine via adb pull</p><pre>adb pull /sdcard/demo.mp4</pre><h3>Sharing your screen</h3><p>Often when you are pairing with dev or doing a mob testing session with the team, You would want them to see what you are trying on the real device. Android studio currently does not include any tool to cast the screen.</p><p>Many people use the Vysor tool for this, however, the free version gives a very bad casting experience.</p><p>Recently I came across a wonderful open-source tool to do this without any quality loss.</p><p>You can quickly <a href="https://github.com/Genymobile/scrcpy#macos">install it via </a><a href="https://github.com/Genymobile/scrcpy#macos">homebrew</a></p><pre>brew install scrcpy</pre><p>And once installed to share your screen, just run:</p><pre>scrcpy --show-touches</pre><p>And you quickly get a screen on your machine with your device screen. Enjoy pairing and sharing stuff with ease. 🙆🏻‍♂️</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/0*XUkGOvyFZnsM7_ic" /></figure><p>scrcpy is a quite powerful and useful tool and I would highly recommend checking it out. It made my life so much simpler and better while testing on android real devices</p><h3>Logging crashes via logcat</h3><p>What if you are testing and the app crashes in the middle. Unless its an easily reproducible crash, sometimes it&#39;s very difficult to isolate that exact log in the middle of a sea of logs that logcat utility generates.</p><p>However fret not, with a single command we can get the logs for the last crash via this simple command.</p><pre>adb -s &lt;emulator_or_real_device_id&gt; logcat -b crash &gt; &lt;file_to_which_you_want_to_write&gt;</pre><h3>Conclusion:</h3><p>Challenge yourself to use more of command line utils and you would realize there are immense value and comfort in using them.</p><p>In case you want to learn more about the wonders of adb, Checkout <a href="https://developer.android.com/studio/command-line/adb">developers.android.com</a></p><p>If you found this post useful, share it with a friend or colleague. Until next time. Happy testing!</p><p>Gaurav Singh is an <a href="https://info.applitools.com/uFGB">instructor</a> at <a href="https://info.applitools.com/uwi7">Test Automation University</a>.</p><p><em>Test Automation University is sponsored by </em><a href="https://info.applitools.com/uw9e"><em>Applitools</em></a><em>.</em></p><p><em>Originally published at </em><a href="https://automationhacks.io/2020/06/11/using-adb-and-cmdline-to-ease-android-app-testing/"><em>http://automationhacks.io</em></a><em> on June 11, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19f64340dae7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/test-automation-university/using-adb-and-cmdline-to-ease-android-app-testing-19f64340dae7">Using adb and cmdline to ease android app testing</a> was originally published in <a href="https://medium.com/test-automation-university">Test Automation University</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[New Challenges in Continuous Delivery]]></title>
            <link>https://medium.com/test-automation-university/new-challenges-in-continuous-delivery-7bf7893fa370?source=rss----27be6f655b45---4</link>
            <guid isPermaLink="false">https://medium.com/p/7bf7893fa370</guid>
            <category><![CDATA[deployment-pipelines]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[continuous-deployment]]></category>
            <category><![CDATA[continuous-delivery]]></category>
            <dc:creator><![CDATA[Lisa Crispin]]></dc:creator>
            <pubDate>Tue, 16 Jun 2020 16:40:29 GMT</pubDate>
            <atom:updated>2020-06-16T16:40:29.762Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rxfRkCyjQdrpVY8W.png" /></figure><p>Continuous delivery and deployment (both abbreviated as “CD”) aren’t new concepts. Jez Humble and David Farley published their <a href="https://www.amazon.com/dp/0321601912?tag=contindelive-20"><em>Continuous Delivery</em></a> book ten years ago. Patrick Debois organized the <a href="https://blog.newrelic.com/engineering/devops-name/">first “DevOpsDays” conference</a> in 2009, and created the #DevOps (also written as devops, devOps and Devops) hashtag.</p><p>Of course, CD is new to many teams. There are lots of publications and courses to help organizations successfully adopt CD. As with any practice, once you’ve mastered the basics, there are always new problems to solve. This past January, I was fortunate to participate in <a href="https://www.deliveryconf.com/">DeliveryConf,</a> a new conference providing a place for people to get deeper technical information about continuous integration (CI) and continuous delivery. Based on what I learned there, along with my own experiences and talking with people in the community, I’d like to share some of the challenges today’s teams may encounter with CD.</p><h3>Testing</h3><p>The DeliveryConf sessions I attended (or watched later on their <a href="https://www.youtube.com/channel/UCDOzFQZN3LYxLiyHaBRxq0Q">YouTube channel</a>) helped me see more ways the technology and practices around continuous delivery have changed how we test.</p><p>Automating the drudge work or toil isn’t a new idea, but <a href="https://twitter.com/jessitron">Jessica Kerr</a> ‘s talk gave me some new perspectives on this. Here are a few examples of how we can use automation to free our brains up for more important work:</p><ul><li>Automation to reduce waiting time for approval or for a machine to be available</li><li>Automate things like procedures, tools, getting credentials, PR review process</li><li>Spin up test environments in the cloud for each new change</li></ul><p>We have fewer bottlenecks, less contention for shared resources, less time wasted waiting for handoffs, and much faster feedback loops. Continuous delivery keeps the software “alive” in our heads so that we are always learning about it.</p><h3>Mapping your pipelines</h3><p>A <a href="https://thinking.visible.is/post/5e4d8d42adf95836b481a49a">value stream</a> map is a technique that comes from Lean manufacturing. It’s a way to visualize how a team delivers something of value to the customers. A value stream map shows all critical steps in the process, focusing only on the things that add value to the product. It includes the time each step in in the value stream takes, and shows time spent waiting for things that don’t add value, like handoffs, as well as waiting for people to make decisions and waiting for resources such as test environments or people with particular specialties to become available.</p><p>In his talk, <a href="https://twitter.com/steveElsewhere">Steve Pereira</a> recommended making a value stream map of your pipeline to detect bottlenecks and shorten feedback loops. His team mapped theirs in Google Sheets so that everyone could see it. They looked at the manual steps, the automated steps, handoffs, and wait times. They worked on one doable slice at a time. Eventually, they were able to cut the time it took to run the whole pipeline down from four weeks to four days!</p><p>Here’s an example I made of what a portion of the value stream map of a pipeline can look like, including the time each step takes to execute, and waiting time in between steps:</p><p>Steve gave some great advice that I also heard in other sessions: Don’t base your own process on what some well-known company is doing — keep it relevant to your own context. Be sure to include customer support folks, marketing, sales… everyone who is affected by your deployment and release process in these mapping discussions. For example, your map should include building support materials and help docs in earlier stages, not right at the end where it might block release.</p><p>Teams that have been doing CI/CD for a while may have “legacy” pipelines — pipelines that have been around for a while. They usually aren’t well documented, nobody on the team quite remembers how they were built or understands them completely, and they might even be unstable. At DeliveryConf, <a href="https://twitter.com/nimbinatus">Laura Santamaria</a> shared her experiences with legacy pipelines. She also recommended making a value stream map for the pipeline, using any documentation you can find, including anything written down in the issue tracking system. This helps understand the pipeline and find ways to stabilize, improve and document it.</p><p>We need visuals to help us see what is not working, and talk about how we will improve. Value stream mapping is a tried-and-true technique, and is simple to do.</p><h3>Beyond “traditional” software apps</h3><p><a href="https://twitter.com/EmilyGorcenski">Emily Gorcenski</a> talked about continuous delivery for machine learning (ML), sharing patterns and pains. I have only basic knowledge about ML, so this was particularly eye-opening for me. I had not realized that ML models have a shelf life.</p><p>Emily explained that data-driven systems are non-deterministic, which makes them difficult to test and improve. They have complex acceptance criteria, are black box and are highly non-linear. Small changes can have an unexpected effect in some other areas. Boundaries are hard to define. She said, “data-driven development is hard, and we’re all kind of bad at it right now.” Long story short: CD with ML is still hard to do. This sound a bit discouraging, but it just takes more experimenting to work on those challenges.</p><p>Multiple teams may be needed to produce data, build and test the ML product, and deal with the technology transitions in between. That means potential delays so that by the time the product is in production, its insights have expired. Addressing these big challenges takes lots of collaboration across disciplines and a lot of sophisticated infrastructure.</p><p>The takeaway for me is that continuous delivery applies to a broad range of software products. CD is being more widely adopted for web-based applications, embedded software, operating system software. Applying it to other types of products such as ML models, BI systems, video products, and audio products — things that teams currently integrate right before they try to release. These types of products pose some of the biggest challenges for continuous delivery today, but they aren’t impossible to overcome. We can keep looking for ways to “shift left” and build quality into all types of products, as well as “shift right” and figure out ways to monitor and learn how they are used in production.</p><h3>Do more than talk about it</h3><p>A strong message at DeliveryConf was to “actually do CD” — one small step at a time. Focus on the most important thing to accelerate. Try small experiments, make them visible, and measure your progress. Even legacy systems can be continuously delivered — we heard from someone who had implemented CD for a 45-year-old <a href="https://en.wikipedia.org/wiki/VAX">VAX</a> assembly application!</p><p>I was struck by the emphasis on small steps and experiments. We hear this same message at conferences that are focused on testing and on agile development. DevOps is about removing the silos within organizations. What if we worked harder to remove silos in our software communities? We all have a lot we can learn from each other. There are lots of virtual conferences happening in the DevOps space, including <a href="https://divops.org/">DivOps</a>, <a href="https://failover-conf.heysummit.com/">Failover Conf</a>, and <a href="https://sessionize.com/2020-all-day-devops/">All Day DevOps</a>. Take advantage of these learning opportunities!</p><p>Automation isn’t the only important part of CD. Organizational culture and relationships among people with different skills and roles are necessary too. Again, this is a message we’ve been sharing in the testing and agile communities, it’s true for just about any activity that helps us solve our customer’s problems with a software product.</p><p>Look at what you can automate next in order to improve or move towards CD. Ideas for what to automate next can come about organically just by having open discussions about everyday challenges we face. Find ways to integrate the important activities that can’t be automated into the pipeline while still getting fast-enough feedback. Look for tools and techniques to help mitigate risks once new changes are in production.</p><p>Lisa Crispin is an <a href="https://info.applitools.com/uE7L">instructor</a> at <a href="https://info.applitools.com/uwi7">Test Automation University</a>.</p><p><em>Test Automation University is sponsored by </em><a href="https://info.applitools.com/uw9e"><em>Applitools</em></a><em>.</em></p><p><em>Originally published at </em><a href="https://lisacrispin.com/2020/03/15/new-challenges-in-continuous-delivery/"><em>https://lisacrispin.com</em></a><em> on March 15, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bf7893fa370" width="1" height="1" alt=""><hr><p><a href="https://medium.com/test-automation-university/new-challenges-in-continuous-delivery-7bf7893fa370">New Challenges in Continuous Delivery</a> was originally published in <a href="https://medium.com/test-automation-university">Test Automation University</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Object-Oriented Principles in Test Code]]></title>
            <link>https://medium.com/test-automation-university/using-object-oriented-principles-in-test-code-67f67d5b9d0?source=rss----27be6f655b45---4</link>
            <guid isPermaLink="false">https://medium.com/p/67f67d5b9d0</guid>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Angie Jones]]></dc:creator>
            <pubDate>Tue, 02 Jun 2020 19:37:11 GMT</pubDate>
            <atom:updated>2020-06-09T22:31:41.063Z</atom:updated>
            <content:encoded><![CDATA[<p>When writing test code, it’s important to exercise the same care that you’d use when developing production code. Here are common ways to use OO principles when implementing test code.</p><p><strong>Encapsulation</strong><br>The Page Object Model design pattern is commonly used in test automation. This pattern prescribes creating a class to interact with each page of the application under test. Within this class are the locator objects for the elements of the web page, and the methods to interact with those elements.</p><p>To keep things clean and safe, it’s best to properly encapsulate by restricting access to the locators themselves and only exposing their corresponding methods.</p><pre> public class SearchPage {<br> <br>    private By searchButton = By.id(“searchButton”);<br>    private By queryField = By.id(“query”);<br> <br>    public void search(String query) {<br>       driver.findElement(queryField).sendKeys(query);<br>       driver.findElement(searchButton).click();<br>    }<br> }</pre><p><em>Example of Page Object Model design pattern. Note: </em><em>driver declaration omitted for brevity.</em></p><p><strong>Inheritance</strong><br>While inheritance should not be abused, it can certainly be useful in test code. For example, given there’s a header and footer component that exists on every page, it’s redundant to create fields and methods for interacting with the elements of these components within every Page Object class. Instead, create a base Page class containing the common fields and methods that exist on every page, and have your Page Object classes inherit from this class. By using this approach, your test code will have access to anything in the header and footer no matter what Page Object they are currently interacting with.</p><p>Another good use case for inheritance within test code is when a given page has various implementations. For example, your app may contain a User Profile page which has different functionality based on roles (e.g. Administrator, Member). While there are differences, there could also be functionality that is the same. Creating two classes and duplicating code in both is not ideal. Instead, create a ProfilePage class which contains the common elements/interactions, and create subclasses (e.g. AdministratorProfilePage, MemberProfilePage) that implement the unique interactions and inherit the common ones.</p><p><strong>Polymorphism</strong><br>Assume we have a convenience method that goes to the User Profile page. This method doesn’t know what type of profile page it is — an Administrator or a Member.</p><p>You’re faced with a design decision here. Do you make two methods — one for each of the profile types? This seems like overkill since they both would do the exact same thing but just have a different return type.</p><p>Instead, return the super class (ProfilePage) since both AdministratorProfilePage and MemberProfilePage are both subclasses of ProfilePage. The test method which is calling this convenience method has more context and can cast accordingly.</p><pre> <a href="http://twitter.com/Test">@Test</a><br> public void badge_exists_on_admin_profile(){<br>    var adminProfile = <br>       (AdministratorProfilePage)page.goToProfile(&quot;<a href="http://twitter.com/admin">@admin</a>&quot;);<br>    //…<br> }</pre><p><strong>Abstraction</strong><br>Abstraction is used sparingly in test code, but there are valid use cases. Consider a type of widget that has been customized for different usages throughout the app. Creating an abstract class that specifies the behaviors expected is helpful when developing classes that interact with specific implementations of that widget.</p><pre>public abstract class ListWidget {</pre><pre>   protected abstract List&lt;WebElement&gt; getItems();</pre><pre>   int getNumberOfItems() {<br>       return getItems().size();<br>   }<br>}</pre><pre>public class ProductList extends ListWidget {</pre><pre>   private By productLocator = By.cssSelector(&quot;.product-item&quot;);</pre><pre>   @Override<br>   protected List&lt;WebElement&gt; getItems() {<br>      return driver.findElements(productLocator);<br>   }<br>}</pre><p>Angie Jones is the Director of <a href="https://info.applitools.com/uwi7">Test Automation University</a>. Check out her courses <a href="https://info.applitools.com/uwi8">here</a>.</p><p><em>Test Automation University is sponsored by </em><a href="https://info.applitools.com/uw9e"><em>Applitools</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67f67d5b9d0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/test-automation-university/using-object-oriented-principles-in-test-code-67f67d5b9d0">Using Object-Oriented Principles in Test Code</a> was originally published in <a href="https://medium.com/test-automation-university">Test Automation University</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tips for Healthy Page Object Model Classes]]></title>
            <link>https://medium.com/test-automation-university/tips-for-healthy-page-object-model-classes-e5071fccaf7f?source=rss----27be6f655b45---4</link>
            <guid isPermaLink="false">https://medium.com/p/e5071fccaf7f</guid>
            <category><![CDATA[page-object-model]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[page-object-pattern]]></category>
            <category><![CDATA[page-object]]></category>
            <dc:creator><![CDATA[Angie Jones]]></dc:creator>
            <pubDate>Tue, 02 Jun 2020 19:36:49 GMT</pubDate>
            <atom:updated>2020-06-09T22:31:17.824Z</atom:updated>
            <content:encoded><![CDATA[<p>The most popular design pattern used in web UI test codebases is the Page Object Model (POM) design pattern. This pattern suggests modeling a class to represent a single page of your system under test. Using this model, the class would contain properties that represent the elements of the UI page and methods that interact with these elements.</p><p>Given this is the Login Page of our application, let’s discuss tips for building a class using POM.</p><figure><img alt="login form with username field, password field, and sign in button" src="https://cdn-images-1.medium.com/max/557/1*x5ojnlgAspPNu7ZZlfK26Q.png" /></figure><h3>The Class</h3><p>We make a single class in our automation framework to represent this page. It’s recommended to ensure the name of the class is representative of the page in the application so that other developers can quickly find the class associated with a given UI page.</p><p>So, in this example, we’d make a class called LoginPage.</p><pre>public class LoginPage {</pre><pre>   private WebDriver driver;</pre><pre>   public LoginPage(WebDriver driver){<br>      this.driver = driver;<br>   }<br>}</pre><h3>Properties</h3><p><em>LoginPage</em> should contain properties for each of the elements on the page that will be used within your tests. The value of these properties are locators to the elements on the actual page. By defining these locators in one place, you won’t need to hardcode them in every place that you use them — thus, eliminating duplication.</p><pre>private By usernameField      = By.id(&quot;username&quot;);<br>private By passwordField      = By.id(&quot;password&quot;);<br>private By signInButton       = By.id(&quot;log-in&quot;);<br>private By rememberMeCheckbox = By.id(&quot;rememberMe&quot;);<br>private By twitterIcon        = By.id(&quot;twitterIcon&quot;);<br>private By facebookIcon       = By.id(&quot;fbIcon&quot;);<br>private By linkedInIcon       = By.id(&quot;linkedInIcon&quot;);<br>private By errorMessage       = By.id(&quot;alert&quot;);</pre><h3>Methods</h3><p>In addition to the properties, the class should also contain methods that enable a test to interact with the application, such as setting input fields and clicking buttons. Here are some tips on designing these methods to be optimally used by your tests.</p><p><strong>Add Getters and Setters</strong></p><p>The purpose of POM classes are to set and get the state of your application. So, you’ll need methods to do this.</p><p>For example, we definitely need to set the username and password fields, so set methods should be added.</p><pre>public void setUsername(String username) {<br>    driver.findElement(usernameField).sendKeys(username);<br>}</pre><pre>public void setPassword(String password) {<br>    driver.findElement(passwordField).sendKeys(password);<br>}</pre><p>We also need to know the content of the error message, so this will need a getter method.</p><pre>public String getErrorMessage() {<br>    return driver.findElement(errorMessage).getText();<br>}</pre><p><strong>Only Add What’s Currently Needed</strong></p><p>Notice, we didn’t add getter and setter methods for every field, because we don’t have a need for them in our tests. Only add what’s currently needed. You can always add more if a new test requires such. This will prevent you from needing to maintain unused code.</p><p><strong>Transitions Should Return New Objects</strong></p><p>You’ll also need methods for clicking links and buttons. However, when your click results in a page change, your method should return a handle to the class representing the UI page you’ve transitioned to.</p><p>For example, if clicking the sign-in button will lead to the home page of your application, then your method should return a handle to the class representing that home page.</p><pre>public HomePage clickSignInButton() {<br>    driver.findElement(signInButton).click();<br>    return new HomePage();<br>}</pre><p>By providing this, all calling tests know that a transition will occur by calling this method, and the test has a handle to the necessary object to continue interacting with the application.</p><p><strong>Don’t Be Afraid to Make Convenience Methods</strong></p><p>Right now, logging into the application would take at least three method calls (setUsername, setPassword, and clickSignInButton). As these three are commonly used together, it makes sense for your class to also provide a convenience method so that your tests only need to call one method.</p><pre>public HomePage login(String username, String password) {<br>    setUsername(username);<br>    setPassword(password);<br>    return clickSignInButton();<br>}</pre><p>Notice we did not implement the logic within this method, but instead called the individual methods. It’s important to have those separate methods available, so that negative tests (e.g. set username but not password) can utilize them.</p><p><strong>Be Mindful of State</strong></p><p>For checkbox elements (or other toggles), simply clicking them may not satisfy the desired intent of the test. For example, what if your test wants the box to be checked, but it’s already checked? Calling a click method would give you the opposite of what you want. Instead, make your method more sophisticated by implementing logic that will only check the box if it’s needed to give the user their desired result. To do this, instead of blindly clicking, accept an argument that specifies intent (i.e. do they want it selected or deselected) and act accordingly.</p><pre>public boolean isRememberUsernameChecked() {<br>    return driver.findElement(rememberMeCheckbox).isSelected();<br>}</pre><pre>public void setRememberUsername(boolean checkIt) {<br>    boolean alreadySelected = isRememberUsernameChecked();</pre><pre>    //only click if the intent does not match the current state<br>    if( (checkIt &amp;&amp; !alreadySelected) || <br>        (!checkIt &amp;&amp; alreadySelected)) {</pre><pre>        driver.findElement(rememberMeCheckbox).click();<br>    }<br>}</pre><h3>Keep POM Classes Neutral</h3><p>Your POM class should be a neutral entity that interacts with and gathers information about your application. Be careful to keep your methods neutral and ensure they are generic enough to be used by any test that wishes to interact with the page. This basically means do not include assertions within these methods.</p><p>By keeping the methods neutral, they can be used in both positive and negative tests. The test can use the information returned from the class for its own purposes in determining whether that information warrants a pass or fail.</p><p>For example, what if our method that gets the error message also fails the test if the message is visible?</p><pre>//This is bad. don&#39;t copy this<br>public String getErrorMessage() {<br>    String message = driver.findElement(errorMessage).getText();<br>    if(message.isDisplayed()){<br>        assert.fail(message);<br>    }<br>    return message;<br>}</pre><p>I cannot reuse this method for tests where I want to make sure an error message is shown when the username or password is incorrect or not provided. This is because the POM class has taken it upon itself to determine that the display of an error message is a failure; when in these cases, that’s not so. Instead, just return the state and allow the test to determine what that means.</p><pre>public String getErrorMessage() {<br>    return driver.findElement(errorMessage).getText();<br>}</pre><h3>Healthy Code Makes Healthy Tests</h3><p>These tips should help you design healthy classes that implement the Page Object Model design pattern. The use of this pattern promotes separation of concerns (e.g. tests vs managing state), reduces code duplication, and provides reusable methods. Happy testing!</p><p>Angie Jones is the Director of <a href="https://info.applitools.com/uwi7">Test Automation University</a>. Check out her courses <a href="https://info.applitools.com/uwi8">here</a>.</p><p><em>Test Automation University is sponsored by </em><a href="https://info.applitools.com/uw9e"><em>Applitools</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5071fccaf7f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/test-automation-university/tips-for-healthy-page-object-model-classes-e5071fccaf7f">Tips for Healthy Page Object Model Classes</a> was originally published in <a href="https://medium.com/test-automation-university">Test Automation University</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning Appium Visual Testing on TAU]]></title>
            <link>https://medium.com/test-automation-university/learning-appium-visual-testing-on-tau-31d521e4719d?source=rss----27be6f655b45---4</link>
            <guid isPermaLink="false">https://medium.com/p/31d521e4719d</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Michael Battat]]></dc:creator>
            <pubDate>Wed, 04 Mar 2020 17:28:07 GMT</pubDate>
            <atom:updated>2020-06-09T22:11:38.822Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QtXR9JYkBWJ-gvV3.png" /></figure><p>I’m learning Appium with visual testing in <a href="https://www.linkedin.com/in/jlipps/">Jonathan Lipps</a> course, <a href="https://info.applitools.com/uEcC">Automated Visual Testing with Appium</a>, on <a href="https://info.applitools.com/uwi7">Test Automation University</a>. I’m familiar with testing but new to <a href="http://appium.io/">Appium</a>, so I figure this is a great way to get started.</p><p>Jonathan knows what he’s talking about when it comes to Appium. He serves as a lead developer and maintainer of the Appium project. His company, <a href="https://cloudgrey.io/">CloudGrey</a>, consults on native mobile app development and testing. And, his company publishes the <a href="https://appiumpro.com/">AppiumPro</a> blog. I assume it’s best to learn from the master.</p><h3>Learning Appium with Visual Testing — Prerequisites</h3><p>Okay, Jonathan already burst my bubble in Chapter 1. He expects me to know Appium. I’m learning Appium, so I’ll do my best to be a quick study. The course uses examples in Java, but the code can be any supported language. Python, Ruby, JavaScript, etc. all work. Jonathan also wants to make sure that I understand automated testing concepts. I do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/0*91hDr6vwl7PtTzAM.png" /></figure><p>Next, I need to have node.js installed and NPM. I need an Appium CLI installation. And, I need to have software that allows me to get Appium Android dependencies installed. Android Studio is one solution. Actually, Jonathan recommends getting all this installed before taking his course, so I figure I’ll go get a little bit more training and get the software installed. Done.</p><p>Then comes the tricky bit — installing OpenCV libraries. OpenCV installs a library of computer vision (ergo “CV”) routines to work with Appium. As Jonathan notes, there’s an easy way and a hard way to install OpenCV. The easy way uses a direct NPM command to build the libraries. He has a Mac and ran into issues with the easy way. I have a Mac and ran into the same issues. So, Jonathan provides a second way to install the OpenCV software using Homebrew.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/0*8NXJhmhifcNxpjWV.png" /></figure><p>The steps I list here are the few steps here you may run through to get Appium up and running on your local machine. As Jonathan points out, this is all documented.</p><p>On to testing.</p><h3>Learning Appium Testing With A Demo App</h3><p>I’m used to testing apps with web element locators. In the case of Jonathan’s demo app, it’s a game. It uses a calculator paradigm with the goal of having the user achieve a certain number by pressing on buttons that perform certain operations. Like this example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/0*0YYqniLfA8gyb4pR.png" /></figure><p>When Jonathan tried to find traditional locators, there was only one leaf node — and it wasn’t a control button. How often does this happen? Often. Your development team can choose one of many frameworks for mobile application development that omits traditional element locators.</p><p>The app source looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X6rtXpy08RyN5tj1.png" /></figure><p>You can try to hard code your tests by region geography on the screen, but what happens when you go from a small format phone to a larger phone — to an Android tablet? Yuck!</p><p>Fortunately, by using OpenCV with Appium you can define the images of buttons that you can save. Take a screen capture, crop the button of interest, and save it in a file accessible to Appium. Later you can pass that image to Appium to find a match and take an action — click. That’s really useful. To reiterate — with OpenCV, Appium can use stored images to find buttons and manipulate the app. That was new to me and really interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/0*Al0YQzLO6I7-T-NA.png" /></figure><p>The specific command you use is:</p><pre>driver.findElementByImage(templateImage);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j8BEXkIWj8nmQxjV.png" /></figure><p>This command returns an ImageElement that can be used for action. The workflow between Appium, OpenCV, your test code, and a stored image looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cXI8ti0xhR3ySudL.png" /></figure><h3>Setting Up Your Test Device as an MJPEG Server</h3><p>Part of learning Appium is learning Appium tricks. From Jonathan’s experience, Appium’s integration with the Android native screen capture and processing can be pretty slow. It can take several seconds to capture one screen. Fortunately, you can install an MJPEG server on your test device. Appium can process the MJPEG server image much more quickly.</p><p>Jonathan uses one such piece of software to connect his Android emulator to his Appium test infrastructure. Called Screen Stream, the software serves the image of the Android device so that a person or piece of software can subscribe to a URL and see what’s on the screen. Jonathan notes that the device or emulator under test must have an IP address accessible to Appium.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/0*Lzn7hDmLJ4oldEWQ.png" /></figure><p>Once you have a stream set up, you need to give Appium access to that stream. Jonathan shows that you set the value of mjpegScreenshotUrl to your appropriate stream URL.</p><h3>Example Test Code</h3><p>As Jonathan mentions, his test code is written in Java, and if it’s not a language you know, his code syntax is easy to read. So, don’t let lack of Java stand in the way of learning Appium. Jonathan spends a little time showing you the code he has created for running his app tests.</p><p>His course presents the test code in easy-to-read chunks. If you’re not a Java person, you might not get all the syntax, but you’ll get why things are organized the way they are. (Note — if you’re interested in learning Java, take <a href="https://info.applitools.com/uDTJ">Angie Jones’s course about the Java language</a> on Test Automation University).</p><p>Jonathan walks you through his test demo of an Android game that uses a calculator as the input device. And, unfortunately, there are no code hooks to drive the UI. So, Jonathan uses the image matching to drive the app. Each active button can be captured and used to drive the behavior.</p><p>You can find the source code in addition to Jonathan’s test excerpts. This will help you see the tests in more detail.</p><h3>Visual Testing with OpenCV</h3><p>Jonathan spends an entire chapter focused on OpenCV for visual testing. Jonathan distinguishes functional test — where the goal of testing is to find unexpected behavior in the input-output behavior of the application — versus visual test — where the goal is finding a visual behavior that may cause a user to find the app either inoperative or unappealing.</p><p>If an app allows the user to enter two numbers and add them, a functional bug results when:</p><ul><li>Either number cannot be entered in the expected numeric fields</li><li>The numeric entry fields can receive numbers but the button click has no effect</li><li>Data entry and the button click works but the presented response does not match the expected sum.</li></ul><p>As a tester, you can also imagine other cases for a functional test: handling negative numbers, non-standard numeric formats, and non-numeric inputs.</p><p>For the same app, an exclusively visual bug exists when:</p><ul><li>Number fields cannot be distinguished on a page</li><li>The button cannot be distinguished on a page</li></ul><p>Note — Appium may be able to execute a functional test even if there are visual bugs, which explains why you need a solution to examine for visual bugs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/0*6mpg9YFwjEr-0muB.png" /></figure><p>To catch visual bugs, OpenCV lets you capture a screen from the mobile device and store it in a location on your local machine or in a network repository. Once you have captured a screenshot, that becomes your baseline for that screen. On subsequent runs, you call OpenCV to compare your screenshot to the saved baseline. OpenCV uses a pixel comparison engine, and the comparison response on the comparator comes back with a value between 0 and 1. The number is roughly analogous to the percentage of pixels unchanged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/0*QrY65w3EXsScgdZD.png" /></figure><h3>Testing with Appium and OpenCV</h3><p>To automate his tests, Jonathan sets up his Java to call OpenCV to capture a screen and compare the image to the baseline. For automation purposes, Jonathan sets 0.99 as his acceptance threshold. Anything that shows 0.99 or above generally has small differences — clock, cell signal level, etc. Anything lower likely shows a noticeable difference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uWlyNlF7YPgb6iBI.png" /></figure><p>You can play with the acceptance criteria to see what works for you.</p><p>One great thing you can do is see the differences in OpenCV. OpenCV will capture a screen of both the checkpoint and the baseline and highlight the differences. You can use this comparison to determine what you want to do, either:</p><ul><li>Declare the difference a bug and pass the information back to developers or</li><li>Declare the difference as intentional and point future tests to the most recent capture, which becomes the new baseline.</li></ul><h3>Real-World Visual Tests with OpenCV</h3><p>Next, Jonathan demonstrates the visual capture with OpenCV. He goes through a demo app and captures two screen images. He saves the images as baselines. Next, he runs the app with screen modifications and captures the new images and runs his pixel comparison. Each screen that has a difference where the comparison falls below 0.99 fails his test.</p><p>Jonathan shows the process you go through using OpenCV. Running through the test the first time, there is no screen capture, so you capture your initial baseline image. The second time you run through the test, you capture screens and your tests either pass or fail. The tests end on the first fail, and you must inspect the compare image to see where the failure occurred.</p><p>In the course, Jonathan ran through his sample application. He ran a test, which included two screen captures. His code captured the screenshot as a baseline if no prior baseline existed. Each screen capture served as its own unique test. After running his test with the baseline application, he then pointed to a modified application and reran his tests using the visual comparison as the validation step. Each screenshot in the second app behaved slightly differently from the initial capture. Then we went through the results.</p><h3>Reviewing the Appium OpenCV Test Results</h3><p>The first test run showed one failure because the Appium run reported the first failure as a failed test. In Jonathan’s first screen, the visual difference occurred because he added a new item to the screen. Because he expected the new behavior, he could set the most recent screen capture as the new baseline for subsequent testing.</p><p>Then, he had to rerun his test. Again, the test run stopped with an image mismatch failure. While the first image passed with the new baseline, the second image now failed. Again, comparing the images showed the highlighted difference, which turned out to be a visually unacceptable change in the location of an action button. In this case, the check image needed to be sent to developers, as this image contained a bug. This test would continue to fail until the bug got resolved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/0*Wp5SaMLih6EJ_WI3.png" /></figure><p>As Jonathan shows, image comparison exposes usability changes that you may or may not desire. More importantly, you learn some of the challenges of OpenCV integration with Appium used in production testing.</p><p>First, you must manage images yourself. If you have a handful of screenshots, that could be doable. But, if you capture many screenshots, that seems problematic. Second, an image is either all-good or else partially buggy. An image with both an acceptable and unacceptable change cannot be partially accepted. So, you need to manage the partial workflow on your own. Finally, the whole notion of a percentage pixel change as acceptance criteria to account for pixels you know will change seems a little imprecise.</p><p>With this, Jonathan moves on to the next chapter — visual testing with Appium and Applitools.</p><h3>Appium with Applitools for Visual Testing</h3><p>Jonathan starts the next chapter helping you learn the drawbacks of using Appium with OpenCV for visual testing:</p><ul><li>OpenCV can be challenging to install</li><li>With OpenCV, you need to manage your own baselines</li><li>Self-Managing images — you also manage compare images</li><li>Image compare errors — you will have reported failures that are not failures</li><li>No support for full-screen comparisons with scrolling screens — something we hadn’t yet covered, but you must manually scroll and capture screens and sync them up. Yuck.</li><li>You must maintain the image comparison code, which will require work from release to release.</li></ul><p>So, funny enough, Jonathan focuses on these limitations of using Appium with OpenCV, and then he proceeds to show how using Applitools overcomes each of these.</p><p>Adding Applitools code — easy. You don’t need to manage a whole image compare library. Applitools does it for you. All you need to do is call into the Applitools Eyes SDK. After that, you need to link to your valid Applitools API Key (best to use a call to a system variable, rather than use the actual key, so that you don’t worry about publishing your key with your code) and start integrating the Applitools code into your Appium tests. Jonathan also goes through the test close steps, including the calls to Applitools to abort an open session in case, for some reason, your test logic skipped a close.</p><p>After that, it’s easy to add the Applitools Eyes calls into your test code. Instead of having to use OpenCV calls that include test compares you run and validate on your own manually, all the calls to Applitools Eyes SDK pull screenshots into Applitools. Later after your tests run, you check out the results.</p><h3>Looking at Applitools Results</h3><p>Here you learn the differences between running Appium with OpenCV and running Appium with Applitools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/0*n0rRYyTB4WNPw3yp.png" /></figure><p>First, your tests run through to completion. Your initial tests, like your initial tests with Appium and OpenCV, run through to completion and capture a baseline image. Unlike with OpenCV, Applitools gives you a useful UI that shows you all the captured images for that run. You don’t have to manage them on your own. When you run your comparison test, the Applitools tests run through to completion while capturing all differences. So, you don’t end up executing multiple test runs to ensure that each visual difference gets captured.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/0*stuxN7bdx06cVCKP.png" /></figure><p>In the Applitools UI, you see all the tests that have been run and ones with differences identified as “Unresolved” but not yet classified as failures. That’s because a difference could be expected or unexpected. You either give a difference a thumbs-up — meaning that the difference was expected (and turning the checkpoint into the new baseline) or a thumbs down — meaning it was a failure.</p><p>One useful thing to note is that you can have Applitools ignore the status bar of the phone entirely and focus just on the app. So, unlike the OpenCV screen captures, which capture the full screen and requires you to do some postprocessing, the Applitools capture can select just the app in question.</p><p>Jonathan shows how the Applitools UI lets you automate the visual capture and streamline your testing. You can review capture history over time for different tests, and see what you have added or changed. It can give you a history of how your app looks over time.</p><h3>Advanced Features — Learning Appium with Applitools</h3><p>Now, Jonathan helps you learn some of the advanced features of Appium with Applitools. First, Applitools lets you capture the full application window — not just a screenshot. You invoke the method:</p><pre>eyes.setForceFullPageScreenshot(true);</pre><p>before your call to eyes.open() to start your test, and Applitools will automatically grab a full-page screenshot. Jonathan shows the difference between the prior and current tests by showing that the prior tests only looked at the first screen of the app, but Applitools could see a range of additions to the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*StIceRtJqRe4EftC.png" /></figure><p>Here, two different runs of the same home screen are captured. The one on the right, the checkpoint, is actually a longer screen and has more content than the baseline on the left. A full capture sometimes finds new content that gets added between test runs, as shown here. But, often, the benefit of full-screen capture for a run is the ability to auto-scroll and stitch together a single image for comparison purposes.</p><p>Next, Jonathan shows how you can use Applitools to treat different regions on a page for visual testing. Sometimes your captured screen includes content that will vary from test to test. Jonathan shows a mobile test of an echo screen, where a user types a test phrase and clicks an on-screen “OK” button. The mobile device then displays the typed text in a different region of the screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/0*Pmc2KpwSTqEFS6-t.png" /></figure><p>When you use a variable to define your test input phrase and your expected output phrase, your Appium functional test will run and, as long as the two phrases match the variable, the test will pass. However, you will have a visual difference if you change the phrase while capturing the image with Applitools. So, Jonathan shows you how to treat a region as “ignored”. You can select a region, identify it as ignorable, and then Applitools ignores the regions.</p><p>Jonathan’s exception demo shows some of the power in Applitools, but the use case might be better for a region that changes independent of the test being run. For instance, if the test screen includes a digital clock region that shows the device time, then that clock will always show a different time. When you run your tests, you might want to ignore the clock region as its region will always change and will always give you an error. You likely want to run and capture multiple versions of the input-output test to handle things like text wrapping and scrolling.</p><h3>Conclusions</h3><p>Wow. Appium provides powerful tools for testing mobile apps in both Android and iOS. While Jonathan’s course focused on Android, and runs his tests on an Android emulator, I can easily imagine doing similar tests using iOS.</p><p>By focusing on apps that lack traditional locators, Jonathan shows how mobile device testing can depend on visual capabilities for both applying tests as well as measuring results. And, he shows both the benefits of using a package like OpenCV to add visual capabilities for both applying tests and measuring results, and he also shows some of the limitations of OpenCV in production visual validation. Those included the challenges of managing images manually as well as having the first visual failure with OpenCV causing a test run to fail and not collecting all the visual differences for a test run.</p><p>Finally, Jonathan does a great job showing how Applitools overcomes a lot of those OpenCV limitations and actually provides a valuable tool for production test automation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5RDIpg0nIaKwRzvq.png" /></figure><p>As always, I print my certificate of completion. Jonathan teaches clearly and concisely. I recommend this course to anyone who wants to use Appium to measure the visual behavior of a mobile application.</p><h3>For More Information</h3><ul><li>Check out the <a href="https://appium.io/docs/en/about-appium/intro/">Appium Documentation</a></li><li>Watch Jonathan’s webinar about <a href="https://www.youtube.com/watch?v=AV8p2aeqsOg&amp;feature=youtu.be?utm_term=&amp;utm_source=web-referral&amp;utm_medium=blog&amp;utm_content=webinar&amp;utm_campaign=&amp;utm_subgroup=">the shifting landscape of mobile automation</a>.</li><li>Visit <a href="https://info.applitools.com/uwi7">Test Automation University</a></li><li>Take <a href="https://info.applitools.com/uDTJ">Angie Jones’s Java course</a> on TAU</li><li>Request an <a href="https://info.applitools.com/uw9h">Applitools demo</a></li><li>Sign up for a <a href="https://info.applitools.com/uw9g">free Applitools account</a></li><li>Check out <a href="https://info.applitools.com/uDlO">our tutorials</a></li></ul><p><em>Test Automation University is sponsored by </em><a href="https://info.applitools.com/uw9e"><em>Applitools</em></a><em>.</em></p><p><em>Originally published at </em><a href="https://info.applitools.com/uEcK"><em>https://applitools.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31d521e4719d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/test-automation-university/learning-appium-visual-testing-on-tau-31d521e4719d">Learning Appium Visual Testing on TAU</a> was originally published in <a href="https://medium.com/test-automation-university">Test Automation University</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Test Your Service APIs through Test Automation]]></title>
            <link>https://medium.com/test-automation-university/test-your-service-apis-through-test-automation-eb4d4fa9eef?source=rss----27be6f655b45---4</link>
            <guid isPermaLink="false">https://medium.com/p/eb4d4fa9eef</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Michael Battat]]></dc:creator>
            <pubDate>Wed, 04 Mar 2020 16:47:48 GMT</pubDate>
            <atom:updated>2020-06-09T22:09:33.188Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sHZq5maQcRUhUduG.jpg" /><figcaption>(Photo by <a href="https://unsplash.com/photos/4hbJ-eymZ1o?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Florian Olivo</a> on <a href="https://unsplash.com/search/photos/programming-language?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a>)</figcaption></figure><p>You need to test your service APIs. You may expand your application into a service API. Or, you may consume someone else’s service API. How do you guarantee the behavior of your own service API? And how do you ensure that your application which depends on a third-party service API? Whether you develop your own service APIs or depend on others, learn to test your service APIs.</p><p>This imperative lies at the heart of the <a href="https://info.applitools.com/uwi7">Test Automation University</a> course, “<a href="https://info.applitools.com/uDTP">Exploring Service APIs through Test Automation</a>”, with instructor <a href="https://www.linkedin.com/in/amber-race-tests/">Amber Race</a> (Twitter: <a href="https://twitter.com/ambertests?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor">@ambertests</a>). We’re offering courses like this to help engineers like yourself think about, and improve, the quality of your services through test automation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EcOv7IAaxTAAtpHK.png" /></figure><h3>A Student in Test Automation University</h3><p>In taking this course as a student, I realized that there are two kinds of service API testers. One tester works with the developers to ensure that the service API code is exercised against the existing specification as well as the API design. The other tester consumes the service API and may choose to test the API in advance of using it in a production application. When I shared this observation with Amber, she reminded me that you, as a service API consumer, are most likely to depend on the service API provider to have tested the API; still, the lessons you learn in this course can help you evaluate a vendor prior to accessing their API.</p><p>Whether you are a service API producer or a service API consumer, you can take advantage of a structured approach to design tests that allow you to explore the behavior and limits of an API. The key to successful service API testing is to imagine prospective failure modes in advance and test against those across a structured approach to considering proper and improper API behavior.</p><h3>POISED to test your APIs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fgS9-QAKPgT3BlnO.png" /></figure><p>Amber Race does a great job with this course. If you are new to testing service APIs, this course can help you understand the concepts and tools available. Amber starts by defining and exploring service APIs. She also spends time describing the POISED model for building API tests:</p><ul><li>Parameters — the range of parameters passed to the API</li><li>Outputs — validating proper outputs for both good and bad parameters</li><li>Interoperability — Ensuring consistency with other service APIs and other calls</li><li>Security — Ensuring access and authorization maintained for API calls</li><li>Errors — Report errors clearly and accurately</li><li>Data — Handle data structures and real data properly and with the appropriate timing</li></ul><p>This structure gives an experienced QA engineer a range of tests to consider applying to the service API.</p><h3>Hands-On With Postman</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ddUxET7hyJKPmzy9.png" /></figure><p>Another great thing about this course is the tools. Amber uses <a href="https://www.getpostman.com/">Postman</a>, a tool you can use to test your service APIs both in development and production. Postman provides for the development of individual tests of each service API you wish to test. You can use built-in scripting and integration with data sources of your choice to turn one-at-a-time tests into a test suite with the power to test across all elements of the POISED model.</p><p>I inferred from the course that Amber had a lot of experience in testing, and that helped her imagine potential failure modes for each element of the POISED model. Think about how an API handles parameters. Sometimes the code for checking a passed parameter can be overly restrictive, resulting in an error when it is passed valid data. Sometimes the code does not check data for type or validity, resulting in unexpected behavior.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hs6IdwLzDZumZ_Y1.png" /></figure><p>Let’s take the example of a parameter that is supposed to be a person’s name. Is the API so restrictive that it only accepts Latin letters? What about punctuation, like hyphenated names, or suffixes like, “, Jr.”? How about names with a space separator, like Mary Claire, or names that include numbers? What about names in non-Latin languages, such as Arabic or Chinese? Will the API field accept any Unicode text? What happens when the Unicode is explicitly articulated, like &amp;#8211? How about a null field? What happens when the passed data is actually a URL?</p><p>The more experienced you are as a tester, the more you can consider the range of potential behaviors that an API may exhibit and the test modes you will want to apply.</p><p>For this reason, you’ll find that the POISED model helps you frame the behaviors you can test against when building tests for your service API.</p><h3>Class Exercises Testing Your Service APIs</h3><p>The course offers plenty of examples of how Postman can help you test your service APIs. For example:</p><ol><li>Parameters — check both valid and invalid parameters. Mishandling of valid input will result in user frustration. Mishandling of invalid input can lead to a host of problems, from <a href="https://en.wikipedia.org/wiki/SQL_injection">security breaches</a> to <a href="https://xkcd.com/327/">data corruption</a>.</li><li>Outputs — ensure that the output for each service API conforms to your specification. Know how the output behaves with unexpected inputs. Check response codes versus expected responses for both successful results and improper parameters. Will the API consumer know what happened and why?</li><li>Interoperability — test both function and performance implications of APIs to know how they behave with others. Say you develop a two API retail application. The first API takes a product specification and returns a list of matching UPC codes. The second API takes a location, radius, and a UPC list, and returns a list of retailers in the radius carrying those products. Testing tells you whether you can pass the retailer list API a batch of UPC codes or if the retailer API behaves best with one UPC at a time.</li><li>Security — know how the API treats active, expired, and invalid credentials. Apply potential vulnerabilities — such as passing parameters that are actually cross-site scripts, and observe results.</li><li>Errors — apply known errors and validate that the API reports errors clearly and unambiguously.</li><li>Data — verify the API behavior handles data structures correctly. Compare parameters entered, such as API parameters, as measured data, such as dates and times. For permanent records, validate that data does not change over time. For databases, compare API behavior for different functions (search, sort, etc) versus database size.</li></ol><h3>Takeaways</h3><p>Amber’s course is a great start to understanding API testing. Postman lets you build lots of automation. Postman also has an instance called Newman that works with a command-line interface. While the course does not cover all the details, the course describes how you can use Newman to integrate API testing into your CI-CD solution.</p><p>My big takeaway is that experience is the best teacher. The more failure modes you have encountered as a QA engineer, the more failure modes you can consider in your API tests.</p><p>Whether you are new to service API testing or an experienced service API tester, this is a great course, as you will end up with tools and approaches to help you test successfully.</p><p>As with all courses in TAU, students who complete the course successfully get a certificate of completion. Here is mine:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ueKuM-T3BhpMVXZw.png" /></figure><p>The next course I plan to take also sounds interesting: <a href="https://info.applitools.com/uEcL">Web Element Locator Strategies</a> with instructor Andrew Knight.</p><h3>Next Steps</h3><p>Find out more about Test Automation University in <a href="https://info.applitools.com/uEcN">this overview with Angie Jones</a>.</p><p>There are plenty of other great courses on Test Automation University. If you haven’t enrolled in Test Automation University yet, It’s easy. <a href="https://info.applitools.com/uwi7">Sign up</a>.</p><p><em>Test Automation University is sponsored by </em><a href="https://info.applitools.com/uw9e"><em>Applitools</em></a><em>.</em></p><p><em>Originally published at </em><a href="https://info.applitools.com/uEcO"><em>https://applitools.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb4d4fa9eef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/test-automation-university/test-your-service-apis-through-test-automation-eb4d4fa9eef">Test Your Service APIs through Test Automation</a> was originally published in <a href="https://medium.com/test-automation-university">Test Automation University</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>