{"id":664,"date":"2014-07-06T10:49:42","date_gmt":"2014-07-06T14:49:42","guid":{"rendered":"http:\/\/qxf2.com\/blog\/?p=664"},"modified":"2017-07-06T14:37:16","modified_gmt":"2017-07-06T18:37:16","slug":"mobile-automation-appium-sauce-labs","status":"publish","type":"post","link":"https:\/\/qxf2.com\/blog\/mobile-automation-appium-sauce-labs\/","title":{"rendered":"Mobile automation: Run Appium tests on Sauce Labs"},"content":{"rendered":"<p><strong>Problem:<\/strong> Maintaining infrastructure for testing your mobile applications on different platforms and browser versions is time consuming.<\/p>\n<h3>Why this post?<\/h3>\n<p>This post was written for the hands on tester looking to explore different tools testers can use for mobile automation. In this post we will show you how to run your Appium tests on <a href=\"https:\/\/saucelabs.com\/\">Sauce Labs<\/a>. We estimate that you need about one hour to try this post on your own. We will start with the test we wrote in a previous post, titled <a href=\"https:\/\/qxf2.com\/blog\/appium-mobile-automation\/\">GET STARTED WITH MOBILE AUTOMATION: APPIUM &#038; PYTHON<\/a>, and modify the test script so it runs on Sauce Labs.<\/p>\n<p><strong>NOTE:<\/strong> Sauce Labs offers a limited free plan for individuals. I recommend that testers take them up on the deal use it to get started. Knowing an extra tool is always useful.  <\/p>\n<hr>\n<h3>Getting started with Appium on Sauce Labs<\/h3>\n<p>1. Sign up for a <a href=\"https:\/\/saucelabs.com\/signup\">Sauce Labs Account<\/a><br \/>\n2. Get your user name and access key<br \/>\n3. Create a test for the app you want to test<br \/>\n4. Update the method to include access key<br \/>\n4. Run the test<br \/>\n5. Check the result<\/p>\n<p><strong>STEP 1: Sign up for a <a href=\"https:\/\/saucelabs.com\/signup\">Sauce Labs account.<\/a><\/strong><br \/>\nYou can sign up for a free Sauce Labs account, where you get 2 hours of automated testing hours per month on all desktop &#038; mobile browsers<\/p>\n<p><strong>STEP 2: Get your user name and access key.<\/strong>Your access key is listed on this page: https:\/\/saucelabs.com\/account. Currently its in the bottom left corner. We will be using this access key in combination with your username to interact with Sauce Labs.<\/p>\n<p><strong>STEP 3: Create a test for the app you want to test<\/a><\/strong><br \/>\nWe will use the same <a href=\"http:\/\/www.appsapk.com\/chess-free\/\">chess app<\/a> used in our <a href=\"https:\/\/qxf2.com\/blog\/appium-mobile-automation\/\">previous pos<\/a>t for our test. You can refer to our<a href=\"https:\/\/qxf2.com\/blog\/appium-mobile-automation\/\"> previous post<\/a> to create test case for the chess app. Make sure you have <a href=\"https:\/\/pypi.python.org\/pypi\/Appium-Python-Client\/0.2\">Appium Python Client<\/a> installed<\/p>\n<p> <strong>STEP 4: Update the method to include access key<\/a><\/strong><br \/>\nUpdate the setUp method to include the username and access key to run your test on sauce Labs<\/p>\n<pre lang=\"python\">\r\ndef setUp(self):\r\n        \"Setup for the test\"\r\n         # Using the apk link directly to launch the app\r\n        app = \"http:\/\/file.appsapk.com\/wp-content\/uploads\/apps-3\/Chess%20Free.apk\"\r\n        self.driver = webdriver.Remote(\r\n            command_executor='http:\/\/$USERNAME:$ACCESS_KEY@ondemand.saucelabs.com:80\/wd\/hub',\r\n            desired_capabilities={\r\n                'platformName': 'Android',\r\n                'deviceName': 'Android Emulator',\r\n                'platformVersion': '4.2',\r\n                'app': app,\r\n                'name': 'Appium Python Android Test for Chess App',\r\n                'appPackage': 'uk.co.aifactory.chessfree',\r\n                'appActivity': '.ChessFreeActivity'\r\n            })<\/pre>\n<p> <strong>STEP 5: Run the test<\/a><\/strong><br \/>\nYou can run the test script the normal way you do. We run it via the command prompt.<\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/06\/Run_chessapp.jpg\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/06\/Run_chessapp.jpg\" alt=\"Run Appium test on sauce\" width=\"671\" height=\"159\" class=\"alignnone size-full wp-image-681\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/06\/Run_chessapp.jpg 671w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/06\/Run_chessapp-300x71.jpg 300w\" sizes=\"auto, (max-width: 671px) 100vw, 671px\" \/><\/a><\/p>\n<p> <strong>STEP 6: Check the result<\/a><\/strong><br \/>\nYou can see the results on your web account. Login to your Sauce Labs account and you should see a result table like the screen shot below.<\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/06\/Sauce_Labs.jpg\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/06\/Sauce_Labs.jpg\" alt=\"Sauce Result\" width=\"1304\" height=\"309\" class=\"alignnone size-full wp-image-674\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/06\/Sauce_Labs.jpg 1304w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/06\/Sauce_Labs-300x71.jpg 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/06\/Sauce_Labs-1024x242.jpg 1024w\" sizes=\"auto, (max-width: 1304px) 100vw, 1304px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/06\/Sauce.jpg\" data-rel=\"lightbox-image-2\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/06\/Sauce-1024x506.jpg\" alt=\"Sauce Detail result\" width=\"474\" height=\"234\" class=\"alignnone size-large wp-image-673\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/06\/Sauce-1024x506.jpg 1024w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/06\/Sauce-300x148.jpg 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/06\/Sauce.jpg 1345w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><\/a><\/p>\n<hr>\n<p>And there it is. You learnt how to run Appium tests on Sauce Labs by adding about a dozen lines of Python code to your existing tests.  <\/p>\n<p><strong>P.S.:<\/strong> You can use this earlier <a href=\"https:\/\/qxf2.com\/blog\/running-selenium-automation-using-sauce-labs-part-2\/\">tutorial<\/a> to figure out how to parameterize your test to have it run on different browsers.<\/p>\n<hr>\n<script>(function() {\n\twindow.mc4wp = window.mc4wp || {\n\t\tlisteners: [],\n\t\tforms: {\n\t\t\ton: function(evt, cb) {\n\t\t\t\twindow.mc4wp.listeners.push(\n\t\t\t\t\t{\n\t\t\t\t\t\tevent   : evt,\n\t\t\t\t\t\tcallback: cb\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n})();\n<\/script><!-- Mailchimp for WordPress v4.10.1 - https:\/\/wordpress.org\/plugins\/mailchimp-for-wp\/ --><form id=\"mc4wp-form-1\" class=\"mc4wp-form mc4wp-form-6165 mc4wp-form-theme mc4wp-form-theme-blue\" method=\"post\" data-id=\"6165\" data-name=\"Newsletter\" ><div class=\"mc4wp-form-fields\"><div style=\"border:3px; border-style:dashed;border-color:#56d1e1;padding:1.2em;\">\r\n  <h1 style=\"text-align: center; padding-top: 20px; padding-bottom: 20px; color: #592b1b;\">Subscribe to our weekly Newsletter<\/h1>\r\n  <input style=\"margin: auto;\" type=\"email\" name=\"EMAIL\" placeholder=\"Your email address\" required \/>\r\n  <br>\r\n  <p style=\"text-align: center;\">\r\n    <input style=\"background-color: #890c06 !important; border-color: #890c06;\" type=\"submit\" value=\"Sign up\" \/>\r\n    \r\n  <\/p>\r\n  <p style=\"text-align: center;\">\r\n    <a href=\"http:\/\/mailchi.mp\/c9c7b81ddf13\/the-informed-testers-newsletter-20-oct-2017\"><small>View a sample<\/small><\/a>\r\n  <\/p>\r\n  <br>\r\n<\/div><\/div><label style=\"display: none !important;\">Leave this field empty if you're human: <input type=\"text\" name=\"_mc4wp_honeypot\" value=\"\" tabindex=\"-1\" autocomplete=\"off\" \/><\/label><input type=\"hidden\" name=\"_mc4wp_timestamp\" value=\"1776073002\" \/><input type=\"hidden\" name=\"_mc4wp_form_id\" value=\"6165\" \/><input type=\"hidden\" name=\"_mc4wp_form_element_id\" value=\"mc4wp-form-1\" \/><div class=\"mc4wp-response\"><\/div><\/form><!-- \/ Mailchimp for WordPress Plugin -->\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>Problem: Maintaining infrastructure for testing your mobile applications on different platforms and browser versions is time consuming. Why this post? This post was written for the hands on tester looking to explore different tools testers can use for mobile automation. In this post we will show you how to run your Appium tests on Sauce Labs. We estimate that you [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48,50,38,47,71,18,31],"tags":[],"class_list":["post-664","post","type-post","status-publish","format-standard","hentry","category-android","category-appium","category-automation","category-mobile","category-mobile-automation","category-python","category-sauce-labs"],"_links":{"self":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/664","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/comments?post=664"}],"version-history":[{"count":29,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/664\/revisions"}],"predecessor-version":[{"id":6211,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/664\/revisions\/6211"}],"wp:attachment":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/media?parent=664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/categories?post=664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/tags?post=664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}