{"id":1410,"date":"2018-08-14T08:33:07","date_gmt":"2018-08-14T15:33:07","guid":{"rendered":"https:\/\/angryweasel.com\/blog\/?p=1410"},"modified":"2018-08-14T09:31:24","modified_gmt":"2018-08-14T16:31:24","slug":"experimenting-with-mobile-automation","status":"publish","type":"post","link":"https:\/\/angryweasel.com\/blog\/experimenting-with-mobile-automation\/","title":{"rendered":"Experimenting with Mobile Automation"},"content":{"rendered":"<p>As I type this, I realize I have a mildly embarrassing gap in my testing career. I don\u2019t recall ever writing any automation for mobile applications.<\/p>\n<p>Maybe that\u2019s not <i>exactly <\/i>true &#8211; nearly 20 years ago, I wrote some automation in C++ to test Windows CE, and some applications that ran on it&#8230;and technically that was an OS used to power Windows Phone for a while (among other devices) &#8211; so I guess the gap is that I have never played with <a href=\"http:\/\/appium.io\/\">Appium<\/a>. We used Appium when I worked on MS Teams for (some?) mobile automation, but I wasn\u2019t directly involved.<\/p>\n<p>Today is my chance.<\/p>\n<h2>TestProject Experiment Number Two<\/h2>\n<p>After my success playing with recorded test automation (I really want to call this recorded test <i>assistance<\/i>) for web, I decided to try the same thing using <a href=\"https:\/\/testproject.io\">TestProject<\/a> to test a mobile application.<\/p>\n<h3>Getting Started &#8211; The Setup<\/h3>\n<p>I was mentally prepared to install the Android SDK (or at least ADB), and spend a bunch of time getting a connection set up, but <i>holy crap &#8211; was it always this easy?<\/i><\/p>\n<p>I already have the TestProject agent running on my computer (for running the web tests), so all I had to do was select Android as my target, and everything else just worked.<\/p>\n<p>Overall, the setup wizard is extremely easy to follow, and worked amazingly well. My phone was already in developer mode, so all I had to do was configure USB debugging, (optionally) disable a few animation features (for testability), and the TestProject web app connected to my phone and showed a mirror on screen in seconds. I thought for sure that I\u2019d spend an hour or more getting this going, but I was wrong.<\/p>\n<p>Granted &#8211; I don\u2019t have much experience here other than half a dozen sessions debugging over ADB, so this sort of thing may be the norm now, so all I can say is setting up a remote development session can\u2019t get much better than this.<\/p>\n<p>The wizard is pretty much the same as the web wizard with one cool addition. Once the connection is configured, I can browse the device packages to choose which one I want to test:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"\" src=\"https:\/\/angryweasel.com\/blog\/wp-content\/uploads\/2018\/08\/null-13.png\" alt=\"\" width=\"501\" height=\"376\" \/><\/p>\n<p>I decided it would be fun to play with some automation for the Twitter app. There\u2019s an option to reset the app before starting, and there\u2019s even a default step added to reset, but for my experiment, I deleted that step.<\/p>\n<p>As in my tests on angryweasel.com, I\u2019m just going to record selecting the top 4 elements from right to left and see what happens.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"\" src=\"https:\/\/angryweasel.com\/blog\/wp-content\/uploads\/2018\/08\/null-14.png\" alt=\"\" width=\"624\" height=\"258\" \/><\/p>\n<p>Note that the steps here are able to pull more friendly names from the package, so the test steps are pretty readable as is.<\/p>\n<h3>Creating Tests<\/h3>\n<p>Using the same test strategy as I did with web tests, I then added validation to ensure that the correct screen showed in the right place.<\/p>\n<p>For each screen, I just used the \u201cValidations\u201d design element to confirm the existence of a particular control. There are probably better ways to do this, but for my quick test, it\u2019s fine.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"\" src=\"https:\/\/angryweasel.com\/blog\/wp-content\/uploads\/2018\/08\/null-15.png\" alt=\"\" width=\"560\" height=\"332\" \/><\/p>\n<p>Similar to what I wrote for web tests, I have some actions with validation.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"\" src=\"https:\/\/angryweasel.com\/blog\/wp-content\/uploads\/2018\/08\/null-16.png\" alt=\"\" width=\"624\" height=\"498\" \/><\/p>\n<h3>The Element Locator<\/h3>\n<p>If you\u2019ve written automation in Appium or Selenium (or other frameworks that rely on IDs, XPaths, etc.) you are already familiar with the game we play to find elements.<\/p>\n<p>One of the other handy features of TestProject is a simple, but useful element locator that makes it easy to discover if the element you\u2019re working with is currently visible. In the example below, I\u2019ve clicked the Find button in the test designer to show me the Twitter Home button.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"\" src=\"https:\/\/angryweasel.com\/blog\/wp-content\/uploads\/2018\/08\/null-17.png\" alt=\"\" width=\"449\" height=\"260\" \/><\/p>\n<p>Pretty cool!<\/p>\n<p>As a nice aside, notice that the screenshot above (unlike the other screenshots), my phone screen fills the emulator (vs. the other screenshots where it fills 70% or so of the emulator screen). The TestProject team fixed the issue practically moments after I reported it.<\/p>\n<h3>A Few Words About Automation<\/h3>\n<p>Let me be the first to point out that this isn\u2019t particularly <i>great<\/i> automation, and that the validation I\u2019m doing probably isn\u2019t what needs to be tested at the UI level for Twitter.<\/p>\n<p>When <i><u>you<\/u><\/i> write UI automation, use it to find bugs that can only be found at the UI level. If it\u2019s a special visual effect that can only be detected via human eyes, then use human eyes to validate the effects.<\/p>\n<p>Of equal importance is your strategy. Don\u2019t start by deciding what to automate. Instead, start with what you want to <i>test<\/i> &#8211; and then use automation to assist your testing. I\u2019ll refer again to <a href=\"https:\/\/blog.testproject.io\/2017\/11\/07\/somethings-rotten-test-automation\/\">my article on the TestProject site<\/a> that expands on these ideas in more depth.<\/p>\n<p>All that said, it seems to me that I could very well use TestProject for <i>proper<\/i> targeted UI tests where they were needed, and that it would serve me well.<\/p>\n<h2>Observations<\/h2>\n<p>I\u2019m still surprised by how easy it was to get up and running testing a mobile app, and the test steps were pretty straightforward and intuitive.<\/p>\n<p>One of the areas where mobile automation really helps is in making sure applications work across a variety of devices. I only have one phone, but TestProject does support working with multiple connected devices to a single desktop. You just connect a USB Hub with a suite of devices, and you have an instant test lab. It\u2019s also worth mentioning that an account can have multiple agents assigned to it. This enables executing tests not only on your desktop (and devices connected to it), but also on remote agents (and devices connected to them) in different locations anywhere in the world. It could be fun to see if TestProject could target a big virtual and real mobile test farm like <a href=\"https:\/\/www.bitbar.com\">BitBar<\/a>, but there\u2019s plenty of flexibility and potential right out of the box.<\/p>\n<p>As with the web tests, I\u2019d love to see a way to view \/ edit the underlying code, but my curiosity was less with mobile apps &#8211; perhaps because my knowledge of Appium is much less than my knowledge of Selenium.<\/p>\n<p>Overall, it seems like a pretty usable and robust choice for most mobile automation tasks.<\/p>\n<p>One more investigation to go where I\u2019ll see how TestProject does with some coded tests.<\/p>\n<h2><\/h2>\n","protected":false},"excerpt":{"rendered":"<p>As I type this, I realize I have a mildly embarrassing gap in my testing career. I don\u2019t recall ever writing any automation for mobile applications. Maybe that\u2019s not exactly true &#8211; nearly 20 years ago, I wrote some automation in C++ to test Windows CE, and some applications that ran on it&#8230;and technically that&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"class_list":["post-1410","post","type-post","status-publish","format-standard","hentry","category-allposts"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/angryweasel.com\/blog\/wp-json\/wp\/v2\/posts\/1410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/angryweasel.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/angryweasel.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/angryweasel.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/angryweasel.com\/blog\/wp-json\/wp\/v2\/comments?post=1410"}],"version-history":[{"count":3,"href":"https:\/\/angryweasel.com\/blog\/wp-json\/wp\/v2\/posts\/1410\/revisions"}],"predecessor-version":[{"id":1429,"href":"https:\/\/angryweasel.com\/blog\/wp-json\/wp\/v2\/posts\/1410\/revisions\/1429"}],"wp:attachment":[{"href":"https:\/\/angryweasel.com\/blog\/wp-json\/wp\/v2\/media?parent=1410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/angryweasel.com\/blog\/wp-json\/wp\/v2\/categories?post=1410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/angryweasel.com\/blog\/wp-json\/wp\/v2\/tags?post=1410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}