Restarting Appium Server could improve various server freezing issues and may improve execution time
|Several threads on Appium’s official forum and in some other discussion platforms , its is evident that a large number of users facing the issue of Appium server freezing which is boosting test execution time significantly. This issue is blocking when iOS 8 device is concerned.
What it means – Freezing?
Well, We might be having a test suite which contains automation scripts that runs over a time period of several hours. If Appium server goes unresponsive in between the test run , creating a situation where script execution is freezed at some point which does not give the indication of either test failure or pass , in fact user has no clue if script is still running or it got failed.
What We assumed:
There is a possibility that Appium server after getting a large instruction sets to execute , eventually gets unresponsive and becomes idle by not responding to client side or not executing the commands at server side.
What could be an effective solution?
If its all about – freezing after several minutes/hours of test run, what if we restart the server in between. A fresh session, a new session Id and each session has to deal with a set of commands, which is light weight.
Of course, I am not saying to keep a watch and restart the server in between manually 😛
How to restart Appium server programatically during run time?
In this case using GUI version of Appium won’t help. We need to run Appium from source and execute commands required for start-stop operation from code itself.
Steps to run Appium from source:
1. Install Node.JS (http://nodejs.org)
2. Clone Appium – git clone https://github.com/appium/appium.git
3. Use following commands (provide password where ever asked)
cd appium
./reset.sh
sudo ./bin/authorize-ios.js # for ios only
node .
To execute command (node .) , which starts appium from JAVA code , we will be needing a JAVA library – Apache Commons exec
If we are using Maven following dependency can be added else the necessary jar file can be added to the build path:
<dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-exec</artifactId> <version>1.3</version> </dependency> How to do it in MAC OSX:To Start Appium from Java Code:public static void start()
{
try
{
CommandLine command = new CommandLine(“/usr/local/bin/node”);
command.addArgument(“/Users/user_name/appium”,false); //Replace user_name with the computer account name
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
Executor executor = new DefaultExecutor();
executor.setExitValue(1);
executor.execute(command,resultHandler);
}
catch(Exception e)
{
APPLICATION_LOGS.error(“Error While Starting Appium Server: “+e.getMessage());
}
}
To Stop Appium Server from Java Code:
public static void stop() { try { CommandLine command = new CommandLine(“/usr/bin/killall”); command.addArgument(“node”); DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler(); Executor executor = new DefaultExecutor(); executor.setExitValue(1); executor.execute(command, resultHandler); } catch(Throwable e) { APPLICATION_LOGS.error(“Error While Stopping Appium Server: “+e.getMessage()); }}
On Windows we can do it in similar fashion by replacing the paths to various executables and replacing with the Windows equivalent command to stop a process.
This way , we can start/stop Appium server in between the test run , according to the implementation of the automation script.
Happy Testing 🙂
- Bring the auto Sync magic of Protractor to Selenium with Java - October 23, 2015
- Restarting Appium Server could improve various server freezing issues and may improve execution time - January 20, 2015
- Appium with iOS 8 and XCode 6 : What’s new? - November 5, 2014
- REST API automation testing using Apache HttpClient – The Approach - October 3, 2014
- An Overview of mobile application : Moving forward to automation - October 1, 2014
- An introduction to REST - September 29, 2014
- Run ChromeDriver with Chrome Driver Service to reduce script execution time significantly - September 26, 2014
- Selenium WebDriver – Get Cookies from an existing session and add those to a newly instantiated WebDriver browser instance. - September 26, 2014
- Simulate Copy Paste action using Java Robot and Clipboard class - September 26, 2014
- Android : How to test if Android Application has memory leaks - August 11, 2014
-
vasu
-
Zetendra
-
https://www.qaautomationsimplified.com/ Abhishek Swain
-
-
Mohammed Faizan