Wednesday 18 April 2018

Appium Architecture and How automation perform on device.

There has been a lot of talk around appium these days as it comes with so many important features which evolve automation.This blog is for those who want to know insides of appium and how automation script running on mobile devices.


So here we are going deep inside the world of automation and will see the how it works.

Following are the topics which we will cover in this blog.

1. Appium and It's Architecture.
2. What is session? and How session established between appium and emulator/ device?
3. What is Bootstrap, UI Automator ? and async method supported by bootstrap.
4. How commands send to device to perform automation?
5. Pros and Cons of appium.

1. Appium and It's Architecture:-

Appium is open source automation tool which used to automate native, mobile web and hybrid application.

Following are the things which come up with appium

1. Appium is open source automation tool.
2. Cross-platform test automation tool for mobile applications.
3. Support native, mobile web application, and hybrid application.
4. Appium is based on client-server architecture.
5. Appium server written in Node.js.
5. Appium does not bound you in any specific language or framework to write or run your test.
6. Recompile of application not necessary while running script.
7. Inherits selenium features hence easy for selenium users.




As we know that appium having client-server architecture and the communication between client and server done by REST API.

Server: Once's server established a connection with a client it receives commands from the client and executes those commands on mobile devices.
Client: It sends commands to the server by using any client libraries(Ruby, Python, Java, JavaScript, PHP, C#, RobotFramework) to perform executed script on emulator/mobile devices.
2. What is session? and How session establish between appium and emulator/ device?

Session:-  Everything happens here is performed based on the context of the session and without session establishment appium not going to perform any automation script on a mobile device.

Whenever a client wants to run any script to perform automation using appium that is the time when appium establish a session between the mobile device and itself.(see above diagram)

For the session, establishment appium generates unique UUID which is unique for every session.

3. What is Bootstrap, UI Automator ? and async methods supported by bootstrap?

Bootstrap is a program which injects appium to interact with UI Automator.

UI Automator is a testing framework which well - suited for writing black-box style test cases, where test cases do not depend on the internal implementation of given application.

Following are some important method which contains by Bootstrap.js

async start(app package, disableAndroidWatchers) : Start test case with the help of android UI Automator.

app package : Target application package name
disableAndroidWatchers: Whether or not to watch android events.

async shutdown() : Stops all interaction between UI Autoator and Bootstrap and destroying all services establish between them

async sendCommand(type, extra, cmdTimeout) : Sending commands to UI Automator with command type.

type: type of command being sent.
extra: extra parameter to send on the device.
cmdTimeout: command response time default is 10000

async sendAction(action, params): Sending commands to UI Automator with given action eg: click or tap.
action: Given action
params: Given parameter for action.

4. How commands send to device to perform automation?

Communication between appium and client did by HTTP'S request. Every time whenever you want to perform automation on mobile device client send an HTTPS request to server and server return a response in form of same HTTP's protocol.

Following are the steps how command sends to device to perform automation.

1.  Whenever we execute any script the client libraries extract values and capabilities from the script and convert it to JSON format which finally sends to Appium  via JSON Wire Protocol.
2. The Appium server injects bootstrap program into device/emulator.
3. Bootstrap has a class called SocketServer which opens a port and continuously listens for commands from appium and forwards for further processing until it receives exit command.
4. The AndroidCommandExecutor class which process commands and sends to UI Automator.( UI Automator is the default framework provided by Google to test any App programmatically in Android. So the commands are executed by UI Automator to perform the operation in device/emulator.)
5. The status of the commands are executed is captured in AndroidCommandResult class which exist in bootstrap.
6. The response is sent to appium.
7. Appium sends the response to the client(the test script) which can log the status or can send to console.


















5. Pros and Cons of Appium

Pros :
1. You don't require to recompile and modify it to perform automation.
2. No framework and language restrictions.
3. Open source and have a very active community in the digital world. etc

Cons :
1. Appium works above 17 API in android before that you have to use selendroid.
2. We can't locate images, to work with images we have to use screen coordinates.

No comments:

Post a Comment