{"id":28723,"date":"2015-10-21T15:11:06","date_gmt":"2015-10-21T09:41:06","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=28723"},"modified":"2015-12-17T10:51:53","modified_gmt":"2015-12-17T05:21:53","slug":"mobile-app-automation-testing-using-appium","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/mobile-app-automation-testing-using-appium\/","title":{"rendered":"Mobile App Automation Testing Using Appium"},"content":{"rendered":"<p><strong>What is Mobile Automation Testing?<\/strong><\/p>\n<p>Mobile Automated testing provides a mechanism to consistently repeat a test procedure and verify application results. It can be effective both for regression testing as well during development. <a title=\"Mobile App Testing\" href=\"http:\/\/www.tothenew.com\/testing\/automated-mobile-application-testing\">Testing mobile applications<\/a> is different and more complex than testing traditional desktop and web applications.<strong><br \/>\n<\/strong><\/p>\n<p><strong>Prerequisites for Mobile Automation Testing on Windows 7:-<\/strong><\/p>\n<ul>\n<li>Eclipse should be installed<\/li>\n<li>Android SDK and APIs for recent versions of Android<\/li>\n<li>Selenium Web driver knowledge.<\/li>\n<li>Java should be installed on system and Mobile device must be connected to the system<\/li>\n<li>Java knowledge<\/li>\n<li>Some basic Knowledge of Mobile.<\/li>\n<\/ul>\n<p><strong>Android Debug Bridge<\/strong>\u00a0(<strong>adb<\/strong>) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device.<\/p>\n<p><strong>Install and Un-install Application using CMD:-<\/strong><\/p>\n<p><strong>Install an App: &#8211; <\/strong><\/p>\n<p><strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 adb<\/strong> <strong>install<\/strong> full_path_of_apk<strong>\u00a0\u00a0 <\/strong><\/p>\n<p><strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 adb install C:\\Users\\TTND\\Downloads\\teamchat.apk<\/strong><\/p>\n<p><strong>Un-Install an App: &#8211; <\/strong><\/p>\n<p><strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 adb<\/strong> <strong>uninstall<\/strong> package_name_of_apk<\/p>\n<p><strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 adb uninstall com. teamchat<\/strong><\/p>\n<p><strong>What is Appium?<\/strong><\/p>\n<ul>\n<li>Appium is an Open source , Cross Platform test automation tool for mobile apps<\/li>\n<li>Supports automation of Native , Hybrid and Mobile Web apps<\/li>\n<li>Based on Client-Server Architecture<\/li>\n<li>Appium Server written in Node.js<\/li>\n<\/ul>\n<p><strong>What are Desired Capabilities?<\/strong><\/p>\n<p>Desired Capabilities are a set of keys and values sent to the Appium server to tell the server what kind of automation session we\u2019re interested in starting up.<\/p>\n<p>File appDir=new File(&#8220;E:\\\\Softwares\\\\APK\\\\News&#8221;);<\/p>\n<p>File app = new File(appDir, &#8220;SplashActivity_2.1.22_latlong.apk&#8221;);<\/p>\n<p>DesiredCapabilities cap=new DesiredCapabilities();<\/p>\n<p>cap.setCapability(&#8220;BROWSER_NAME&#8221;, &#8220;&#8221;);<\/p>\n<p>cap.setCapability(&#8220;VERSION&#8221;, &#8220;4.4.4&#8221;);<\/p>\n<p>cap.setCapability(&#8220;devicename&#8221;, &#8220;ANDROID&#8221;);<\/p>\n<p>cap.setCapability(&#8220;platformName&#8221;, &#8220;ANDROID&#8221;);<\/p>\n<p>cap.setCapability(&#8220;appPackage&#8221;, &#8220;com.shopclues&#8221;);<\/p>\n<p>cap.setCapability(&#8220;appActivity&#8221;, &#8220;com.shopclues.SplashActivity&#8221;);<\/p>\n<p>cap.setCapability(&#8220;app&#8221;, &#8220;SplashActivity_2.1.22_latlong.apk&#8221;);<\/p>\n<p><strong>Setup Mobile Device For Automation using Appium:-<\/strong><\/p>\n<ul>\n<li>For setting up mobile devices, we have to verify that whether developer options is enable or not.<\/li>\n<li>USB Debugging is allowed or not.<\/li>\n<li>For Real device, Android version must be<strong>2 <\/strong>or above.<\/li>\n<\/ul>\n<p><strong>Step By Step Installation:-<\/strong><\/p>\n<p><strong>STEP 1:- <\/strong>Install and Setup JAVA<\/p>\n<p><strong>STEP 2:-<\/strong> Install Android SDK. By default it will be installed in C:\\Program Files\\Android. You have to just copy the folder and paste it to some other drive. <strong>E.g.:-<\/strong> <strong>D:\\SDK<\/strong><\/p>\n<p><strong>STEP 3:- <\/strong>Now setup <strong>ANDROID_HOME<\/strong><\/p>\n<p><strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 D:\\SDK<\/strong><\/p>\n<p><strong>STEP 4:-<\/strong>Setup <strong>Tools<\/strong> and <strong>Platform<\/strong> <strong>Tools<\/strong> Path in User Variable<\/p>\n<p><strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 D:\\SDK\\platform-tools;D:\\SDK\\tools;<\/strong><\/p>\n<p><strong>STEP 5:-<\/strong> Restart the system <strong>(Strongly Recommended)<\/strong><\/p>\n<p><strong>STEP 6:-<\/strong> Setup Eclipse and Pin to Task Bar<strong> (Right Click on Eclipse.exe and set it to Pin to Taskbar)<\/strong><\/p>\n<p><strong>STEP 7:-<\/strong> Launch Eclipse and create a new project<\/p>\n<p><strong>STEP 8:-<\/strong> Check android is install on your system or not. Open cmd <strong>&#8211;&gt;<\/strong> type <strong>adb<\/strong> on cmd prompt<\/p>\n<p><strong>STEP 9:-<\/strong> Check Connected Device <strong>adb devices<\/strong><\/p>\n<p><strong>STEP 10:-<\/strong> Install Device PC Suite<\/p>\n<p><strong>STEP 11:-<\/strong> Enable Developer Option and allow USB Debugging<\/p>\n<p><strong>Step 12:-<\/strong> After completing all these steps, just type <strong>adb devices <\/strong>on cmd prompt<\/p>\n<p><strong>Step 13:- adb install D:\\Mobile_Setup\\apk\\ ShopClues.apk<\/strong><\/p>\n<p>It will install the application on the connected device with Success message.<\/p>\n<p><strong>Step 14:-<\/strong> Download Appium<strong> https:\/\/bitbucket.org\/appium\/appium.app\/downloads\/<\/strong><\/p>\n<p><strong>Step 15:-<\/strong> Install Appium and click on Appium.exe<\/p>\n<p><strong>Step 16:-<\/strong> Launch Appium<\/p>\n<p><strong>Step 17: &#8211;<\/strong> Setup is complete and now we have to start the Mobile Automation:-<\/p>\n<ul>\n<li>Attach your Mobile Device with your system using adb devices command and verify that device is attached to the system.<\/li>\n<li>Start Eclipse and create a new program for mobile device automation.<\/li>\n<li>Launch Appium.<\/li>\n<li>After launching Appium Run the Script.<\/li>\n<\/ul>\n<p><strong>Step 18: &#8211;<\/strong> Launch UI Automator (Available at <strong>D:\\SDK\\tools<\/strong> location) It will help us to find out the mobile objects.<\/p>\n<p><strong>How to find objects on mobile app:- <\/strong><\/p>\n<ul>\n<li>Connect the device.<\/li>\n<li>Launch the desired app<\/li>\n<li>Launch UI Automator(\/SDK\/tools\/UI Automator)<\/li>\n<li>Click on Green Colored Icon Below and move the cursor to desired object and Select the Object Properties.<\/li>\n<\/ul>\n<p><strong>Step 19:- Object locators:-<\/strong><\/p>\n<p>We have prioritized the list of locators to be used when scripting.<br \/>\n<strong>Id, Name, Linktext, Partial Linktext, Tag Name, class name, Css, xpath<\/strong><\/p>\n<p><strong>Step 20: &#8211;<\/strong> How to get .apk file properties:- <strong>aapt.exe<\/strong> <strong>dump<\/strong> <strong>badging<\/strong> <strong>apk file path<\/strong><\/p>\n<p><strong>Step 21:- Required JAR\u2019s<\/strong><\/p>\n<p>Import Selenium Stand Alone Server Jar (<strong>selenium-server-standalone-2.47.0<\/strong>) and <strong>Java-client.Jar 3.1.0<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Mobile Automation Testing? Mobile Automated testing provides a mechanism to consistently repeat a test procedure and verify application results. It can be effective both for regression testing as well during development. Testing mobile applications is different and more complex than testing traditional desktop and web applications. Prerequisites for Mobile Automation Testing on Windows [&hellip;]<\/p>\n","protected":false},"author":737,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":6},"categories":[1818,1772],"tags":[1978,1979,1561,1976],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/28723"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/737"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=28723"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/28723\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=28723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=28723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=28723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}