With mobiles capturing the digital world market, and mobile apps becoming the main source of connection between users and service providers; it has become extremely important to test these apps.
Testing mobile apps require the testers to consider the number of devices and operating systems these apps can execute over. And considering the vast number of devices available to the users, it becomes an extremely challenging task. And hence testers require an app that makes these tasks easy for the testers and Appium is one of them.
What is Appium?
Appium basically a User interface testing tool for mobile applications. It is a free and open-source tool with unmatchable support of a huge online community. Appium supports all three native, web and hybrid application testing. It also has an added benefit of testing apps in physical devices as well as both on emulator or simulator. And, as a cherry on the top Appium also supports cross-platform application testing i.e. It can be used to test both Android and iOS applications.
Appium is not dependent on the OS of the mobile device. Its framework depends on the device type and it can convert Selenium Webdriver commands into UIAutomator (Android) or UIAutomation (iOS) commands.
To understand Appium let us first understand its architecture. The most important is its client/server nature.
Server: If we use selenium RC, Appium works more or less like selenium server in selenium RC. It forms a connection between the mobile device and the client. Since Appium is scripted in Node.js there is no need to install it again.
A REST API is revealed when the Appium server is started to the client. A client then begins a session with JSON ‘desired capabilities’ object. It starts between client and server.
Prerequisite to use Appium
How Appium works?
Once all the prerequisites for Appium are ready, set up the machine with a server which issues REST API. The client then sends a connection and a command request. Appium then will start to execute the commands on the mobile OS. The response of it is in the form of HTTP. To execute the HTTP response, mobile test automation tool is used that returns a UI output.
Install Appium Desktop:
To install Appium server you will require Appium Studio, which is an Open source GUI app. It includes all the pre-requisites to install and use Appium Server.
Appium studio comes along with
Step 1) Visit http://appium.io/ and click on Download Appium.
Step 2) Select .exe file and download it for Windows. The size of the file is around 162MB. We suggest you to use broadband connection for faster download.
Step 3) Click on the downloaded exe.
Step 4) you are not required to install Appium for the Windows. It will directly get executed from the .exe file. After you will click on the .exe you would see the following image for some time.
If you are a Mac user, you will have to install the .dmg file.
Step 5) After this you will see a Server Start Window. It fills the default host and port option. But, allow you to change them later. It also reveals the version of Appium being used.
Step 6) when you will click start Server Button, it will launch a new server for defined host and port. Below you can see Server log output.
Step 7) Click New Session Window.
Step 8) enter Desired Capabilities and start a session.
Appium like Selenium IDE has an ‘Inspector’ to record and Playback. It helps to record and play native application behavior. It inspects DOM and develops the test scripts in required language. However, Microsoft Windows does not support Appium inspector currently. In Windows, it can launch the Appium Server but cannot inspect elements. In windows UIAutomator viewer can be used as a replacement to Inspect elements.
How to start Appium Inspector on Mac machine?
Step 1) Download Appium server and start it with the default IP Address 0.0.0.0 and the port 4725.
Step 2) click the ‘Choose’ button. It will ask you to browse and select test file from the local drive.
Step 3) Start Simulator on Mac machine.
Step 4) Click ‘Launch’ button seen on the top right corner. It will enable a blue color icon. When you will click on this blue color icon, it will start Appium inspector and Simulator.
Step 5)– Appium Inspector displays the element hierarchy in column-wise structure. It also permits the user to perform actions like Tap, Swipe, etc. to use their respective buttons.
Step 6) Use the ‘Stop’ button to stop recording.
Step 1) Install Android SDK in your device.
Go to Control panel >> System and Security >> System. Click on ‘Advanced System Settings ‘present on the left panel. From ‘System Properties’ pop up, click on ‘Advanced’ tab and then click on “Environment Variables” button.
Step 2) in the ‘Environment variables’ pop up, ‘double click on ‘Path’ and set ANDROID_HOME variable. The Android_Home variable will point to your SDK directory. In the path, also include the complete SDK folder path.
Step 3) Start your Android emulator (make sure that the Android Debugging option has been enabled on the Android device. Check the Debugging Option by going to Device Settings >> Developer Options >> Check “Debugging Option”).
Step 4) initiate Command Prompt and navigate to Android SDK’s
Step 5) – Execute ‘adb devices’ command. It will display the list of connected device in Command Prompt window.
Step 6)– Execute ‘adb start-server’ command. It will allow Appium to send commands to your Android device.
Step 7) Go to Appium directory and click on Appium.exe file to start Appium.
Step 8) Without changing IP address or port number click the ‘Launch’ button. And it will initiate your Appium console
Step 9) Next, Click the ‘Start’ button, to start executing Appium server on your system.
Step 1)) Download ADT eclipse plugin or ADT bundled
Step 2) Open Eclipse and Create a new Project >> Package >> Class
Step 3) Import Selenium library and Testng to your new project.
Step 4) Develop a small test Program for ‘Calculator.app’ to sum two numbers.
Select Appium Server and Android Emulator from ‘AVD Manager’ and Click Run >> TestNG. It will execute the ‘Calculator.app’ on selected emulator and the result will be shown under Eclipse console using a TestNG framework.
Appium has many pros and cons too. Here are some of the pros and cons of Appium you must know.
If you’d like to discuss how you can introduce mobile automation to your project, and how automation tools from Tritusa Consulting can help, please get in touch with our team.