{"id":539,"date":"2018-08-27T12:02:57","date_gmt":"2018-08-27T06:32:57","guid":{"rendered":"http:\/\/nxglabs.in\/etech\/?p=539"},"modified":"2018-08-31T18:05:49","modified_gmt":"2018-08-31T12:35:49","slug":"best-way-to-automate-mobile-application-appium","status":"publish","type":"post","link":"https:\/\/nxglabs.in\/etech\/best-way-to-automate-mobile-application-appium\/","title":{"rendered":"Best way to Automate mobile application : Appium"},"content":{"rendered":"<p>Welcome to our\u00a0Appium Tutorial!<\/p>\n<p>Nowadays automated test scripts are very important for mobile application testing. Through the automation script, we can reduce our time for the testing.<\/p>\n<p>However, there is a number of automation testing tools for mobile application. We are going to discuss the <strong>Appium Automation Tool.\u00a0<\/strong>Before we begin, let&#8217;s first know\u00a0<strong>Appium.<\/strong><\/p>\n<p><strong>What is Appium?<\/strong><\/p>\n<p>Appium is an open source and cross-platform tool. Appium supports the android as well as iOS applications. We can automate the scripts in six languages as Java, Ruby, Python, PHP, JavaScript, and C#. With the help of jar files, we can automate the mobile application. Appium supports from android version\u00a02.3 to 4 by using\u00a0Appium&#8217;s Selendroid driver and android versions 4.2 and up are supported via Appium&#8217;s uiautomatorviewer. We can run the scripts on real devices as well as on Android emulators.<\/p>\n<p><strong>Pre-requisites for Appium : (Script for<\/strong> Android<strong> Application)<br \/>\n<\/strong><br \/>\nTo follow along with this guide, you would be requiring following things ready:<\/p>\n<p>1.Java JDK installed with Java_Home<\/p>\n<p>2. Android SDK installed withAndroid_Home<\/p>\n<p>3.ADB which comes under android path- C:\\Users\\user\\android-sdks\\platform-tools .<\/p>\n<p>4.Eclipse IDE.<\/p>\n<p>5.Node js for windows.<\/p>\n<p>6.Jar files for appium\u00a0&#8211; to get this go to the appium-java .<\/p>\n<p><strong>Installations:<\/strong><\/p>\n<p>After following the prerequisites, follow this guide to\u00a0<strong>how to install appium on windows<\/strong> operating system.<strong><br \/>\n<\/strong><\/p>\n<p><strong>1.Java Application:<b>\u00a0JDK (Java SE Development Kit) \u2013 [ Compulsory ]<\/b><\/strong><\/p>\n<ul>\n<li>Before installing Jenkins on the system first we need to install Java in the system.<\/li>\n<li>Go to the URL of Java software and download it as per the operating system i.e. Windows.<\/li>\n<\/ul>\n<figure id=\"attachment_316\" class=\"wp-caption alignnone\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-316 size-full\" title=\"Java SE Development Kit\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/2-2.jpg\" alt=\"\" width=\"1942\" height=\"1000\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/2-2.jpg 1942w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/2-2-300x154.jpg 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/2-2-768x395.jpg 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/2-2-1024x527.jpg 1024w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/2-2-800x412.jpg 800w\" sizes=\"(max-width: 1942px) 100vw, 1942px\" \/><figcaption class=\"wp-caption-text\">Java SE Development Kit<\/figcaption><\/figure>\n<p>Link:\u00a0<a href=\"http:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/jdk8-downloads-2133151.html\">http:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/jdk8-downloads-2133151.html<\/a><\/p>\n<ul>\n<li>After successfully download the software we need to install in the system.<\/li>\n<li>Once the installation is done completely we need to set\u00a0an environmental variable in the\u00a0system.<\/li>\n<li>To set the\u00a0<strong>environmental\u00a0variable<\/strong>\u00a0we have to follow some steps-\n<ul>\n<li>Go to the Control Panel \u2014&gt;All Control Panel Items \u2013&gt;System.<\/li>\n<li>Click on Advanced System Settings<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-288 size-full\" title=\"Control Panel - Jenkins \" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/3.jpg\" alt=\"\" width=\"1175\" height=\"690\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/3.jpg 1175w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/3-300x176.jpg 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/3-768x451.jpg 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/3-1024x601.jpg 1024w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/3-800x470.jpg 800w\" sizes=\"(max-width: 1175px) 100vw, 1175px\" \/><\/p>\n<ul>\n<li>In the System properties, click on the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.<\/li>\n<li>Give the complete path of Java by creating or editing Java_Home.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-289 size-full\" title=\"Java_Home\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/4.jpg\" alt=\"\" width=\"1352\" height=\"717\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/4.jpg 1352w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/4-300x159.jpg 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/4-768x407.jpg 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/4-1024x543.jpg 1024w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/07\/4-800x424.jpg 800w\" sizes=\"(max-width: 1352px) 100vw, 1352px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.Android<\/strong> <strong>SDK\u00a0installation<\/strong><\/p>\n<ul>\n<li>Go to the Android SDK link. Download the android SDK as per the operating system. Here I have downloaded the installation file for Windows operating system min. version should be\u00a0Android SDK \u2265 16.<\/li>\n<li>link &#8211; https:\/\/developer.android.com\/studio\/<\/li>\n<li>After installing it. Set the environmental path of Android SDK.<\/li>\n<li>Please refer above\u00a0point to set the environmental path in windows operating system.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-589\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/1-1.png\" alt=\"\" width=\"1583\" height=\"797\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/1-1.png 1583w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/1-1-300x151.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/1-1-768x387.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/1-1-1024x516.png 1024w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/1-1-800x403.png 800w\" sizes=\"(max-width: 1583px) 100vw, 1583px\" \/><\/p>\n<p><strong>3.Eclipse\u00a0 IDE<\/strong><\/p>\n<ul>\n<li>\u00a0Go to the link of eclipse IDE.download it.<\/li>\n<li>\u00a0link &#8211; https:\/\/www.eclipse.org\/downloads\/<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-590 size-full\" title=\"download eclipse\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/2-1.png\" alt=\"\" width=\"1594\" height=\"675\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/2-1.png 1594w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/2-1-300x127.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/2-1-768x325.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/2-1-1024x434.png 1024w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/2-1-800x339.png 800w\" sizes=\"(max-width: 1594px) 100vw, 1594px\" \/><\/p>\n<ul>\n<li>Install it. Now open the eclipse. We need TestNG software to run the test cases<\/li>\n<li>Go to Help &#8211;&gt; install new software. add&#8211;&gt; type name : TestNG<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-591 size-full\" title=\"download testNG\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/3.png\" alt=\"\" width=\"1562\" height=\"832\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/3.png 1562w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/3-300x160.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/3-768x409.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/3-1024x545.png 1024w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/3-800x426.png 800w\" sizes=\"(max-width: 1562px) 100vw, 1562px\" \/><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>Type Location: <strong><a href=\"http:\/\/beust.com\/eclipse\/\">http:\/\/beust.com\/eclipse\/<\/a><\/strong><\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-595 size-full\" title=\"Available Software\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/7-1.png\" alt=\"\" width=\"1188\" height=\"841\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/7-1.png 1188w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/7-1-300x212.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/7-1-768x544.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/7-1-1024x725.png 1024w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/7-1-800x566.png 800w\" sizes=\"(max-width: 1188px) 100vw, 1188px\" \/><\/p>\n<ul>\n<li>Accept the licenses and install it<\/li>\n<\/ul>\n<p><strong>4.Node.js<\/strong><\/p>\n<ul>\n<li>\u00a0Go to the link of Node.js and download it.<\/li>\n<li>\u00a0link &#8211;\u00a0https:\/\/nodejs.org\/en\/download\/<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-596 size-full\" title=\"Node.js\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/8.png\" alt=\"\" width=\"1565\" height=\"805\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/8.png 1565w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/8-300x154.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/8-768x395.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/8-1024x527.png 1024w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/8-800x412.png 800w\" sizes=\"(max-width: 1565px) 100vw, 1565px\" \/><\/p>\n<ul>\n<li>Install it.<\/li>\n<\/ul>\n<p><strong>5.Appium tool windows [By this we can get the appium GUI]<\/strong><\/p>\n<ul>\n<li>\u00a0Go to the link of appium and download it.<\/li>\n<li>\u00a0link &#8211; http:\/\/appium.io\/<\/li>\n<li>Install it as per the operating system. we will download the file as per windows operating system.<\/li>\n<li>By the help of this, we can get the inbuilt inspector to find out the elements.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-597 size-full\" title=\"Appium Libraries\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/9.png\" alt=\"\" width=\"1572\" height=\"782\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/9.png 1572w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/9-300x149.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/9-768x382.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/9-1024x509.png 1024w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/9-800x398.png 800w\" sizes=\"(max-width: 1572px) 100vw, 1572px\" \/><\/p>\n<h3><strong>Steps to Install the Appium Tool<\/strong><\/h3>\n<ul>\n<li><strong><em>Step<\/em> 1<\/strong>. Install the Java application.<\/li>\n<li><strong><em>Step<\/em> 2<\/strong>. Open a command prompt.<\/li>\n<li>Type the <strong>command:\u00a0<\/strong>\u00a0&#8220;node \u2013v&#8221;\u00a0 (to check the node version. we will get the installed version of node)<\/li>\n<\/ul>\n<p><strong><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-598 size-full\" title=\"command prompt\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/10.png\" alt=\"\" width=\"839\" height=\"540\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/10.png 839w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/10-300x193.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/10-768x494.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/10-800x515.png 800w\" sizes=\"(max-width: 839px) 100vw, 839px\" \/><\/strong><\/p>\n<ul>\n<li><strong><em>Step<\/em> 3<\/strong>. Install Appium via NPM command.<\/li>\n<li>Type the <strong>command: &#8220;<\/strong>npm install -g appium&#8221;<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-599 size-full\" title=\"command prompt 2\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/11.png\" alt=\"\" width=\"806\" height=\"824\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/11.png 806w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/11-293x300.png 293w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/11-768x785.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/11-800x818.png 800w\" sizes=\"(max-width: 806px) 100vw, 806px\" \/><\/p>\n<ul>\n<li><strong><em>Step<\/em> 4<\/strong>. After installation done successfully. Check the version of installed appium<\/li>\n<li>Type the <strong>command:<\/strong>\u00a0&#8220;appium \u2013v&#8221;<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-600 size-full\" title=\"command prompt 3\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/12.png\" alt=\"\" width=\"798\" height=\"776\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/12.png 798w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/12-300x292.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/12-768x747.png 768w\" sizes=\"(max-width: 798px) 100vw, 798px\" \/><\/p>\n<ul>\n<li><strong><em>Step<\/em> 5<\/strong>. To start appium server<\/li>\n<li>Type the <strong>command: &#8220;<\/strong>appium&#8221;<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-601 size-full\" title=\"command prompt - appium\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/13.png\" alt=\"\" width=\"805\" height=\"814\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/13.png 805w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/13-297x300.png 297w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/13-768x777.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/13-800x809.png 800w\" sizes=\"(max-width: 805px) 100vw, 805px\" \/><\/p>\n<p>We will get the appium version as well as will get the appium listener with the port number.\u00a0 This is useful to run an android application on the listening port successfully.<\/p>\n<h3><strong>Steps to create the simple script for the Android application.<\/strong><\/h3>\n<p><strong>Step<\/strong> <strong>1<\/strong>. To create the project first open eclipse.<\/p>\n<p>Go to File &#8211;&gt; New &#8211;&gt; Other &#8211;&gt; Select Maven Project &#8211;&gt;select simple project and workspace\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&#8211;&gt; type groupid artifact id etc and click on finish.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-603 size-full\" title=\"Maven Project\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/15.png\" alt=\"\" width=\"1599\" height=\"758\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/15.png 1599w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/15-300x142.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/15-768x364.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/15-1024x485.png 1024w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/15-800x379.png 800w\" sizes=\"(max-width: 1599px) 100vw, 1599px\" \/><\/p>\n<p>We will get the project in eclipse on the left-hand side.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-606 size-full\" title=\"eclipse project \" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/18.png\" alt=\"\" width=\"1566\" height=\"415\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/18.png 1566w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/18-300x80.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/18-768x204.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/18-1024x271.png 1024w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/18-800x212.png 800w\" sizes=\"(max-width: 1566px) 100vw, 1566px\" \/><\/p>\n<p><strong>Step 2<\/strong>. Now we will get the pom.xml file.<\/p>\n<p>Set the properties of Test-NG and appium in that file. Here we will mention the TestNG version and appium\u00a0jar files java version.<\/p>\n<p><strong>Step 3<\/strong>. Then click on src\/test\/java to create the package.<\/p>\n<p>Src\/test\/java &#8211;&gt; new &#8211;&gt; package. Here Name of the package: &#8220;appiumPackage&#8221;<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-608 size-full\" title=\"Java project \" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/20.png\" alt=\"\" width=\"865\" height=\"509\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/20.png 865w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/20-300x177.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/20-768x452.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/20-800x471.png 800w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/p>\n<p><strong>Step<\/strong> 4. Now create a class in a created package<\/p>\n<p>Right click &#8211;&gt; new &#8211;&gt; class<\/p>\n<p>A]Type new class name. Once a class is created then we will get it as in the figure. This class will be used to create appium android driver for appium.<\/p>\n<p>B]Now again create another class for Testcase execution. Here is the testcase class to run the test cases using appium.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-621 size-full\" title=\" Testcase \" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/31.png\" alt=\"\" width=\"1551\" height=\"322\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/31.png 1551w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/31-300x62.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/31-768x159.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/31-1024x213.png 1024w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/31-800x166.png 800w\" sizes=\"(max-width: 1551px) 100vw, 1551px\" \/><\/p>\n<p><strong>Step 5<\/strong>. Now go to the src\/test\/resources &#8211;&gt; copy and paste the apk\u00a0in that folder<\/p>\n<p>Right click&#8211;&gt;new&#8211;&gt;folder<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-610 size-full\" title=\"parent folder\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/22.png\" alt=\"\" width=\"860\" height=\"720\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/22.png 860w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/22-300x251.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/22-768x643.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/22-800x670.png 800w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/p>\n<p><strong>Step 6<\/strong> .Type desired capabilities in the <strong>DemoClassForAppium.java<\/strong><\/p>\n<p>Here we need the code &#8211;<\/p>\n<p><em>\u00a0final File classpathRoot = new File(System.getProperty(&#8220;user.dir&#8221;));<\/em><\/p>\n<p><em>final File appDir = new File(classpathRoot, &#8220;\/src\/test\/resources\/app\/&#8221;);<\/em><\/p>\n<p><em>final File app = new File(appDir, &#8220;Demo.apk&#8221;); \/\/ give the path of apk.<\/em><\/p>\n<p><em>DesiredCapabilities caps = <strong>new<\/strong> DesiredCapabilities();<\/em><\/p>\n<p><em>caps.setCapability(&#8220;browserName&#8221;, &#8220;&#8221;);<\/em><\/p>\n<p><em>caps.setCapability(&#8220;platform&#8221;, &#8220;ANDROID&#8221;);\u00a0 \/\/Assign platform name of your application.<\/em><\/p>\n<p><em>caps.setCapability(&#8220;deviceName&#8221;, &#8220;name of your device&#8221;); \/\/Name of your device<\/em><\/p>\n<p><em>caps.setCapability(&#8220;platformVersion&#8221;, &#8220;version of your mobile&#8221;); \/\/Version of your device<\/em><\/p>\n<p><em>caps.setCapability(&#8220;appPackage&#8221;, &#8220;package of your application&#8221;); \/\/package of the application<\/em><\/p>\n<p><em>caps.setCapability(&#8220;appActivity&#8221;, &#8220;activity of your application&#8221;); \/\/app activity of the application<\/em><\/p>\n<p><em>This is very important. We have to mention the URL of the Appium server.<\/em><\/p>\n<p><em>driver = <strong>new<\/strong> <u>AndroidDriver<\/u>(<strong>new<\/strong> URL(&#8220;http:\/\/0.0.0.0:4723\/wd\/hub&#8221;), caps);<\/em><\/p>\n<p><strong>Steps 6.\u00a0<\/strong>Before run the application we have to set build path by providing archive files to the project.<\/p>\n<p>For this We have to Build Path&#8211;&gt; Configure Build Path&#8211;&gt;Libraries&#8211;&gt; Add external Jars&#8211;&gt; Apply and close.<\/p>\n<p><strong>Step 7<\/strong>.Now we will use UIAutomator.To get UIAutomator, Go to the android sdk. And you will get the path of UIAutomator as below-<\/p>\n<p>C:\\Users\\user\\android-sdks\\tools\\uiautomatorviewer<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-709 size-full\" title=\"UIAutomator\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/25-1.png\" alt=\"\" width=\"1600\" height=\"849\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/25-1.png 1600w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/25-1-300x159.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/25-1-768x408.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/25-1-1024x543.png 1024w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/25-1-800x425.png 800w\" sizes=\"(max-width: 1600px) 100vw, 1600px\" \/><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-710 size-full\" title=\"Automator Viewer\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/26-2.png\" alt=\"\" width=\"1600\" height=\"861\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/26-2.png 1600w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/26-2-300x161.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/26-2-768x413.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/26-2-1024x551.png 1024w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/26-2-800x431.png 800w\" sizes=\"(max-width: 1600px) 100vw, 1600px\" \/><\/p>\n<p>By using this we can find the elements of the application. We can get the elements by resource-id, Xpath, accessibility id, text etc.<\/p>\n<p>Example: Here I have given you the example for resource id. You can get the elements by other ways also.<\/p>\n<p>@Test(priority = 0)\u00a0 \/\/(Always give the priority to test case)<\/p>\n<p><strong>public<\/strong> <strong>void<\/strong> sampleTest() <strong>throws<\/strong> InterruptedException{<\/p>\n<p>driver.findElement(MobileBy.<em>id<\/em>(&#8220;com&#8230;..&#8221;)).click();<\/p>\n<p>System.<strong><em>out<\/em><\/strong>.println(&#8220;We are able to click on yes Button and allowing to proceed&#8221;);<\/p>\n<p>Thread.<em>sleep<\/em>(100);<\/p>\n<p>}<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-711 size-full\" title=\"Test case for Appium Java\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/28-1.png\" alt=\"\" width=\"1578\" height=\"410\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/28-1.png 1578w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/28-1-300x78.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/28-1-768x200.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/28-1-1024x266.png 1024w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/28-1-800x208.png 800w\" sizes=\"(max-width: 1578px) 100vw, 1578px\" \/><\/p>\n<p><strong>Step 8<\/strong>. Once after done this, we have to run the application. To run the application we have to right click on the application. Select RunAs&#8211;&gt; TestNG Test.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-618 size-full\" title=\" TestNG Test\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/30.png\" alt=\"\" width=\"813\" height=\"613\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/30.png 813w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/30-300x226.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/30-768x579.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/30-800x603.png 800w\" sizes=\"(max-width: 813px) 100vw, 813px\" \/><\/p>\n<p>i]Before we have to do this step. We have to attach the android device by USB. And start\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0the\u00a0appium server.<\/p>\n<p><strong>Start Appium Server<\/strong>: A]If you are starting the appium server by command prompt then we have type in cmd as : appium<\/p>\n<p>B]If you are starting appium by GUI desktop. then open appium gui and start the server.<\/p>\n<p>ii] Connect the real device to the system using adb\u00a0and run the script using appium tool.<\/p>\n<p>We can get the result of test cases on the console.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-617 size-full\" title=\"result of test cases on console\" src=\"http:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/29.png\" alt=\"\" width=\"1340\" height=\"547\" srcset=\"https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/29.png 1340w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/29-300x122.png 300w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/29-768x314.png 768w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/29-1024x418.png 1024w, https:\/\/nxglabs.in\/etech\/wp-content\/uploads\/2018\/08\/29-800x327.png 800w\" sizes=\"(max-width: 1340px) 100vw, 1340px\" \/><\/p>\n<p>In this above Article, I just explained how we can easily automate the android application using Appium Tool. Hope you all liked it. Thank You..!!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to our\u00a0Appium Tutorial! Nowadays automated test scripts are very important for mobile application testing. Through the automation script, we can reduce our time for the testing. However, there is a number of automation testing tools for mobile application. We are going to discuss the Appium Automation Tool.\u00a0Before we begin, let&#8217;s first know\u00a0Appium. What is &hellip;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[47,40,45,42,43,41,49,44,46,48],"_links":{"self":[{"href":"https:\/\/nxglabs.in\/etech\/wp-json\/wp\/v2\/posts\/539"}],"collection":[{"href":"https:\/\/nxglabs.in\/etech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nxglabs.in\/etech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nxglabs.in\/etech\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/nxglabs.in\/etech\/wp-json\/wp\/v2\/comments?post=539"}],"version-history":[{"count":56,"href":"https:\/\/nxglabs.in\/etech\/wp-json\/wp\/v2\/posts\/539\/revisions"}],"predecessor-version":[{"id":726,"href":"https:\/\/nxglabs.in\/etech\/wp-json\/wp\/v2\/posts\/539\/revisions\/726"}],"wp:attachment":[{"href":"https:\/\/nxglabs.in\/etech\/wp-json\/wp\/v2\/media?parent=539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nxglabs.in\/etech\/wp-json\/wp\/v2\/categories?post=539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nxglabs.in\/etech\/wp-json\/wp\/v2\/tags?post=539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}