What is Appium?

8th January 2024|Yogesh Loganathan

Appium is an open-source automation tool. It can be used to automate test cases in mobile, web, native and hybrid applications on Android/IOS mobile and Windows desktop platforms.  It supports multiple programming languages like Java, Python, PHP etc.

The Difference between Native, Web and Hybrid apps:

Native apps are the apps that are written using Android, IOS or Windows SDKs. These applications can be used only after installation on the device.

Web apps can be accessed using browsers of the device we are using. Mobile web apps and desktop web apps can be accessed using mobile and desktop browsers, respectively.

 As the name says, hybrid apps are the combination of both native and web apps. These apps work in the same manner as web apps, but are downloaded to the device like native apps.

Why Appium?

 Appium is open source and a cost-effective solution for automating mobile app testing. It is cross-platform compatible and can be used to test apps on both Android and iOS devices. It gives flexibility to use the testing framework of their choice as it can be easily embedded with different frameworks.

How to start?

1.Download Java and set JAVA_HOME in environment variables.

2.Download Android studio for Emulators.

3. Get the Android installation path in Local and set SDK location in ANDROID_HOME Environment variable.

  1. Open Android studio and go to the SDK Manager and SDK tools tabs.
  2. Uncheck “Hide Obsolete Packages”, now “Android SDK Tools (Obsolete)” will be displayed.
  3. Check “Android SDK Tools (Obsolete)” and click on Apply.
  4. Check for the tools' folder in “C:\Users\<<OwnerName>>\App Data\Local\Android\SDK\”.
  5. bin should be inside tools folder.
  6. Add both bin and tools path in Environment variable Paths.

4.Create and configure Emulator in Android studio.

  1. Go to Virtual Device Manager and click on Create Device
  2. Select the appropriate device and Android version needed and download Android image (OS of Android).
  3. Give any device name and select orientation and click on Finish.
  4. Created Virtual device should be shown in the list.

5.Open Emulator in local.

  1.   Once the Virtual device/Emulator is created, it can be opened directly by clicking on the start button in actions or by using command prompt.

How to open VD/Emulator using Android studio “Virtual Device Manager”:

 A screenshot of a cell phone

Description automatically generated

How to open VD/Emulator using command prompt:

  • Open the command prompt and go to path C:\Users\<<OwnerName>>\App Data\Local\Android\SDK\emulator.
  • Use the command “emulator -list-avd” to get the list of VD/Emulators crea

A screenshot of a computer

Description automatically generated

6. Download node.js.

7.Set NODE_HOME in Environment variables.

8. Set npm in Environment variables.

9. Download Appium Server from node.

10. Install any IDE (Eclipse/IntelliJ) and create project and configure Appium libraries. 

11. Create a Maven project and add dependencies of Appium-Java-client and Selenium Java and TestNg in pom.xml and build the projectA computer screen shot of a code

Description automatically generated  

12. Start Appium Server

      a. From Command prompt (Use command “appium”):

  A black background with white text

Description automatically generated             

    b. From Appium Application:

          Open Appium app > Click on start S

  A screenshot of a computerDescription automatically generated

   A screenshot of a computer programDescription automatically generated     

13. Create a base class and add the required Desired Capabilities and valid URL (Appium server URL).

 Desired Capabilities:

  A screen shot of a computer code

Description automatically generated

Parameters for the above

   Text, letter

Description automatically generated                    

Note: APPLICATION_PATH in Desired Capabilities is the path where the .exe file of the test application exists.

14. Initiate AppiumDriver (Android/Ios) and pass URL and desired capabilities object as parameters.             

     Text

Description automatically generated with medium confidence

15. Make sure that Appium server and emulator are up and running.

  • Use the command “adb.exe devices” to get the List of devices attached. It’ll show all devices online (both emulator and devices connected using USB)

A black background with white text

Description automatically generated     

16. Annotate properly (using Test Ng) and run a simple test to check whether configurations are done properly.

HOW TO START APPIUM SERVER USING CODE:

  1. Create an object for “AppiumServiceBuilder” class.
  2. Set required values by calling the below-mentioned methods using the object created for AppiumServiceBuilder class.
  • withIPAddress method passing IP Address as a parameter.

               withIPAddress (IP_Address)

  • usingPort method passing port as parameter. usingPort(port)
  • withAppiumJS method passing the path of appium main (java script) file which will be inside appium > build > lib > main.js withAppiumJS (new File(path))
  • usingDriverExecutable method passing node.exe file path.

              usingDriverExecutable (new File(path)

  • withArgument method passing base path.

              withArgument (BASEPATH, "/wd/hub")

OPTIONAL:

  • withArgument method passing session override and log level flag.

              withArgument (GeneralServerFlag.SESSION_OVERRIDE)

             withArgument (GeneralServerFlag.LOG_LEVEL, "debug")

NOTE: BASEPATH, GeneralServerFlag.SESSION_OVERRIDE and GeneralServerFlag.LOG_LEVEL are from GeneralServerFlag enum which implements “ServerArgument” interface.

       3.Create an object for “AppiumDriverLocalService” class and call buildService method by passing“AppiumServiceBuilder” object.

          AppiumDriverLocalService service = AppiumDriverLocalService.buildService(builder)

       4. Call start() using the “AppiumDriverLocalService” object.

           service.start()

   A computer screen shot of text

Description automatically generated

      Parameters for the above: 

A close-up of a sign

Description automatically generated

HOW TO STOP APPIUM SERVER USING CODE:

Call stop() using the “AppiumDriverLocalService” object created while starting the server.

service.stop()

    A close up of text

Description automatically generated

Conclusion:

Since we have many platforms for testing, Appium is the one which is more flexible, cost-efficient and has good community support.  Though it has some disadvantages, it is good to choose automation tools based on the requirement and the nature of the application which is under test.

 

If this is of interest and you would like to explore further then please contact info@anyaconsultancy.com

For more information on ACS, technology and domain expertise, please visit our website at www.anyaconsultancy.com

About Anya Consultancy Services

ACS is a global SI headquartered in the UK with offices On-shore in England and Scotland, Near-shore in Romania and Portugal and Off-shore in India.

We started in 2010 as an integration specialist, working with big enterprises to integrate ERP, Manufacturing, Warehouse and e-Commerce solutions.

Since that time, we have widened our portfolio via a mix of organic growth and acquisitions to encompass a Hi-tech engineering capability, our successful IT services business and a growing portfolio of SaaS solutions from in store radio station management through to Digital catering solutions feeding ‘000s of NHS patients every day.

A diagram of software developmentDescription automatically generated

 

 

 

 

 

    •