as

Saturday, 16 May 2015

Selendroid - Android application testing tool

What is Selendroid?
Selendroid is an android application testing tool.

Setting up environment
  1. Download and Install Java. Set up JAVA_HOME and JRE_HOME. Download and Install Android SDK. For example - D:\Program Files\Java\jdk1.8.0_45
  2. Set up ANDROID_HOME. Also configure system path variable to include Java and Android tools. For example D:\Android\sdk
  3. Set up device (Virtual device or Android phone) on which tests have to be run. If you are using real Android phone for testing then please enable developer option by tapping on the version menu (found in settings->About device)  7 times. Once Developer option becomes visible, you should enable usb debugging. Then you can attach your device to laptop using usb cable. For the first time, your device mac address will be registered in device manager, You also need to accept a message with RSA key fingerprint to acknowledge the registration on your phone. To check that your device is up and running, you must run the command - "adb devices". This command displays all the devices attached to computer.
  4. Download Selendroid jar files and test apk application.
First program to test application using Selendroid

import io.selendroid.client.SelendroidDriver;
import io.selendroid.common.SelendroidCapabilities;
import org.openqa.selenium.WebDriver;

public class Sele {

 /**
  * @param args
  */
 public static void main(String[] args) throws Exception{
    
  WebDriver driver;
  SelendroidCapabilities x;
  x = new SelendroidCapabilities("io.selendroid.testapp:0.15.0");
  driver = new SelendroidDriver(x);

 }

}

Running First program using Selendroid
  1. Run the command java -jar selendroid.jar -aut selendroid-test.apk. You should see the server running at http://localhost:4444/wd/hub/status
  2. then run above code.

Troubleshooting Issues
  1. To fix the error - "Error occurred while resigning the app selendroid - set the Java_home to home directory.
  2. You may see error saying "The requested application under test is not configured in selendroid server. - select correct app id from url". To fix this error, make sure that you have given correct app id.
  3. emulator: ERROR: x86 emulation currently requires hardware acceleration! This error comes when you try to launch virtual device. To fix this you will need to install Intel HAXM software.

Other important points to consider -
  1. You need to download Selendroid client jar file from http://repo1.maven.org/maven2/io/selendroid/selendroid-client/0.15.0/  - download client. This is required as SelendroidDriver class and other classes are defined inside it.
  2. You can use tool at below url to inspect the application structure. http://localhost:4444/inspector

Important Android tools -
  1. Android device monitor shows all devices attached to computer and also gives details about app package name, activity name and also we can view the app structure and code
  2. With AVD Manager, we can manage android devices, attach new devices.
  3. With SDK Manager, we can install/uninstall android api packages.
  4. with chrome://inspect/#devices, you can inspect web apps in chrome - 
Below screenshot shows the device monitor.


What do you think on this topic? Please express your opinion or ask any question through comment below. You can write to me at reply2sagar@gmail.com

No comments:

Post a Comment

Leave your valuable feedback. Your thoughts do matter to us.

Sponsored Links

Popular Posts

Comments

ShareThis