Up and running with: Selendroid

This is the second article in our series on new, popular or otherwise interesting tools used in test automation. You can read all posts within this series by clicking here.

What is Selendroid?
Selendroid is a test automation framework for testing Android native and hybrid applications. Selendroid tests are written using the Selenium Webdriver client API, which allows for full integration with existing Selenium frameworks.

Where can I get Selendroid?
Selendroid can be downloaded from the Selendroid website.

How do I install and configure Selendroid?
Before you can start setting up Selendroid and writing tests, you need to download and install the latest Android SDK first. Clear instructions on how to do this can be found here. Make sure you also create at least one Android virtual device (AVD) and test whether it can be run properly, as we are going to need this virtual device to deploy our app under test and run our Selendroid tests on it.

NOTE: The instructions specify the creation of an AVD with the latest Android version (KitKat, API level 19). This is all wonderful, but if you’re (like me) working on a virtual machine or any other machine with limited resources, you’re probably better off creating an AVD based on Android Gingerbread (API level 10). You will need to install the correct SDK components for that API level using the Android SDK Manager. Oh, and it’s probably wise as well to use GPU emulation by enabling ‘Use host GPU’ in the AVD settings while you’re at it. This will make your test run much faster. Or, in my case, it will make your test run at all.

After you have successfully installed the Android SDK, you can install Selendroid following these instructions. When you’ve done so, start Selendroid and load the test app (the .apk file) they provide here. When you point your browser to

http://localhost:4444/wd/hub/status

you’ll see something similar to this:

Selendroid is running
As you can see, Selendroid is running and it has detected our newly created AVD.

Creating a first test script
Now we’re done setting up our environment we can go to the interesting part. To start mobile testing using Selendroid, create a new Java project, add the Selendroid and Selenium .jar files as dependencies and create the following script:

public static void runSelendroidTest() throws Exception {
		
	// specify test capabilities (your 'test environment')
	SelendroidCapabilities capa = new SelendroidCapabilities("io.selendroid.testapp:0.9.0");
		
	// explicitly state that we want to run our test on an Android API level 10 device
	capa.setPlatformVersion(DeviceTargetPlatform.ANDROID10);
		
	// explicitly state that we use an emulator (an AVD) for test execution rather than a physical device
	capa.setEmulator(true);

	// start a new WebDriver
	WebDriver driver = new SelendroidDriver(capa);
		
	// execute a very simple test
	WebElement inputField = driver.findElement(By.id("my_text_field"));
	Assert.assertEquals("true", inputField.getAttribute("enabled"));
	inputField.sendKeys("Selendroid");
	Assert.assertEquals("Selendroid", inputField.getText());
		
	// quit testing
	driver.quit();
		
}

The comments in the code really explain it all. You can instantly see that Selendroid tests are indeed very similar to regular Selenium tests, with the exception that they are run on an app that is deployed on an AVD rather than on a website that you access using a browser.

Running your test
Running your Selendroid tests is done just like you’d run Selenium tests, so there’s really no need to go into more detail on that here.

When you run your tests, you’ll see that an Android emulator (the AVD) is started, the app is loaded, tests are executed and the emulator is closed again. Selendroid can also be used to execute tests on apps that are deployed on physical Android devices connected to your machine, something I haven’t tried myself.

A screenshot of the test app

Useful features
Selendroid offers a lot of to the tester that wants to create more useful and more complex tests. For example, you can very accurately emulate a user swipe action from right to left using the following code snippet:

WebElement pages = driver.findElement(By.id("some_id"));
TouchActions flick = new TouchActions(driver).flick(pages, -100, 0, 0);
flick.perform();

Using the instructions presented here, just try and see for yourself what you can do with Selendroid. And of course, please share your experiences here.

Further reading
Again, the official Selendroid site can be found here. It offers a lot of information on the possibilities and features of Selendroid.

Happy mobile testing!

156 thoughts on “Up and running with: Selendroid

  1. Hi,
    Am using selendroid..am new to this. am using in android device.. I just installed the apk file my real device. how i use that..jar file kindly help me

    • Hi Satish,

      I haven’t tested Selendroid in combination with an actual Android device to be honest. But I think it works the same as with an emulator? Please check http://selendroid.io for more information on how to perform tests on your device.

  2. Creating a first test script
    Now we’re done setting up our environment we can go to the interesting part. To start mobile testing using Selendroid, create a new Java project, add the Selendroid and Selenium .jar files as dependencies and create the following script:

    ?
    public static void runSelendroidTest() throws Exception {

    // specify test capabilities (your ‘test environment’)
    SelendroidCapabilities capa = new SelendroidCapabilities(“io.selendroid.testapp:0.9.0”);

    // explicitly state that we want to run our test on an Android API level 10 device
    capa.setPlatformVersion(DeviceTargetPlatform.ANDROID10);

    // explicitly state that we use an emulator (an AVD) for test execution rather than a physical device
    capa.setEmulator(true);

    // start a new WebDriver
    WebDriver driver = new SelendroidDriver(capa);

    // execute a very simple test
    WebElement inputField = driver.findElement(By.id(“my_text_field”));
    Assert.assertEquals(“true”, inputField.getAttribute(“enabled”));
    inputField.sendKeys(“Selendroid”);
    Assert.assertEquals(“Selendroid”, inputField.getText());

    // quit testing
    driver.quit();

    where we need to push this code. Android or Java Project

    please answer quickly

  3. You said here as, create a new java project but application going to run in android emulator.

    My doubt here is could we need to create new java project or new android project to paste that given code.

    • I started a new Java project. Then, when you run your Selendroid test case, Selendroid automatically launches the test on the emulator (the AVD) you specified. I never used a specific Android project.

      Hope this helps.

    • That’s strange. And you used the exact same code to type a text into the text field and check it?

      WebElement inputField = driver.findElement(By.id(“my_text_field”));
      Assert.assertEquals(“true”, inputField.getAttribute(“enabled”));
      inputField.sendKeys(“Selendroid”);
      Assert.assertEquals(“Selendroid”, inputField.getText());

      If you did that, I’m stumped as well. According to the Selendroid homepage, this is all that it should take, and over here it worked fine..

  4. i used same code only and i got this error in console after app ran and opened.

    Exception in thread “main” java.lang.RuntimeException: Stub!
    at junit.framework.Assert.assertEquals(Assert.java:14)
    at main.java.io.selendroid.sample.Sample.runSelendroidTest(Sample.java:33)
    at main.java.io.selendroid.sample.Sample.main(Sample.java:43)

  5. Thanks for the solution and quick reply.

    I used quick solution and application worked successfully.

    After all test complete i got this error in eclipse.

    Sep 12, 2014 12:01:46 PM org.apache.http.impl.execchain.RetryExec execute
    INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {}->http://localhost:4444: The target server failed to respond
    Sep 12, 2014 12:01:46 PM org.apache.http.impl.execchain.RetryExec execute
    INFO: Retrying request to {}->http://localhost:4444

  6. Pingback: Open Source Android Testing Tools

  7. Hi Bas,

    I’ve moved to this thread from previous.
    How to get the test app running at all on your Android emulator, do I need to install “selendroid-test-app-0.11.0.apk,” on the emulator?

    I can get Selendroid running and it has detected my AVD?
    “”””””
    Thanks for your detail sharing. But I still get an error while run your scripts in eclipse.
    Error on “WebDriver androidDriver = new SelendroidDriver(capa);”
    *********java.lang.NoSuchMethodError: org.openqa.selenium.remote.CommandInfo.(Ljava/lang/String;Lorg/openqa/selenium/remote/http/HttpMethod;)V *********************
    I don’t know what did the error mean, I’m all using 0.11.0 version?

    One question: Why there is resigned-selendroid-test-app-0.11.0.apk, do I need to install this apk in android emulator? I don’t understand what’s this apk used for? “”””””””””””””””””””””””””””

    Please help me on that, thanks in advance.

    Regards,
    Fion

    • Hi Fion,

      when you start Selendroid using

      java -jar selendroid-standalone-0.11.0-with-dependencies.jar -app selendroid-test-app-0.11.0.apk

      you automatically load the test app (selendroid-test-app-0.11.0.apk). You can check that the application(s) and the devices are recognized by opening a browser and navigating to http://localhost:4444/wd/hub/status

      When you start your emulator in your Selendroid code, it should automatically start the test app as well.

      • Hey,
        Thanks for your update, so I don’t need to do anything on emulator, right?

        Yes, i run the command: “java -jar selendroid-standalone-0.11.0-with-dependencies.jar -app selendroid-test-app-0.11.0.apk” and when open http://localhost:4444/wd/hub/status, apparently it can detect my installed emulators.

        And when I try to run scripts in Eclipse,
        package TestGoogle;

        import io.selendroid.SelendroidCapabilities;
        import io.selendroid.SelendroidDriver;
        import io.selendroid.device.DeviceTargetPlatform;

        import org.openqa.selenium.By;
        import org.openqa.selenium.WebDriver;
        import org.openqa.selenium.WebElement;
        import org.testng.Assert;
        import org.testng.annotations.Test;

        public class TestEmulator {
        @Test
        public void test() throws Exception {

        SelendroidCapabilities capa = new SelendroidCapabilities(“io.selendroid.testapp:0.11.0”);
        capa.setPlatformVersion(DeviceTargetPlatform.ANDROID18);
        capa.setEmulator(true);

        WebDriver androidDriver = new SelendroidDriver(capa);

        WebElement inputField = androidDriver.findElement(By.id(“my_text_field”));
        Assert.assertEquals(“true”, inputField.getAttribute(“enabled”));
        inputField.sendKeys(“Selendroid”);
        Assert.assertEquals(“Selendroid”, inputField.getText());
        androidDriver.quit();

        }

        }

        There is nothing opened on Emulator.
        Error come up on this script ” inputField.sendKeys(“Selendroid”);” I don’t know what to do?

        java.lang.NoSuchMethodError: org.openqa.selenium.remote.CommandInfo.(Ljava/lang/String;Lorg/openqa/selenium/remote/http/HttpMethod;)V
        at io.selendroid.SelendroidCommandExecutor$1.(SelendroidCommandExecutor.java:32)
        at io.selendroid.SelendroidCommandExecutor.(SelendroidCommandExecutor.java:28)
        at io.selendroid.SelendroidDriver.(SelendroidDriver.java:72)
        at TestGoogle.TestEmulator.test(TestEmulator.java:25)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)

        • Hi Fion,

          I’ll have to look into this, but time is a little scarce at the moment as I’m busy moving to another job. I will try to do so as soon as possible.

          • Thanks so much for your time, I’m appreciated. Just finished your staff first, if you have time, you can help me on this.

            Regards,
            Fion

          • Hi Tony,

            to be honest I never looked into this problem anymore. I’m not actively involved in mobile testing anymore (at least not for the moment) and I don’t think I’ll have time to dive into it again anytime soon, I’m sorry.

          • “java.lang.NoSuchMethodError: org.openqa.selenium.remote.CommandInfo.(Ljava/lang/String;Lorg/openqa/selenium/remote/http/HttpMethod;)V”

            This is the error I receive.

          • Hi Zachary,

            I’ll definitely take a look into this issue in the coming week. Thanks for reporting it.

            Nice to see an ex-colleague on here, by the way! I left Sogeti (NL) around five years ago.

  8. Pingback: 2014 非常好用的开源 Android 测试工具 | 我爱互联网

  9. Pingback: 2014 非常好用的开源 Android 测试工具 | 陈学虎

  10. Pingback: 2014 非常好用的开源 Android 测试工具 | 无锋网

  11. Pingback: 2014 非常好用的开源 Android 测试工具 – Android开发中文站

  12. Pingback: 2014 非常好用的开源 Android 测试工具 | 大分享网

  13. Bas ,

    I am testing one mobile app. using selendroid. In my app. I need to click on camera and take a photo so what element Id I can use to take a photo?

    I am not getting any id for camera click , can you please help?

    • Is that the standard Android camera app or do you have a custom function in your application to take pictures?

      I’m not sure whether it is at all possible to use the standard Android camera app from Selendroid, I think I read somewhere that it’s definitely not possible to do such a thing in iOS with Appium, but I’m not sure if the same goes for Selendroid + Android..

    • Hmm.. In that I have no idea how you could get this to work, or even if it’s possible at all. I have no idea if and how Selendroid can control builtin apps.

    • Funny you should say that, I’m working on a TestNG post at the moment! First time I’m working with TestNG myself, so it will take a bit of time to get used to it, but keep posted!

  14. Bas ,

    Can I run test in selendroid when device connected using WIFI? Or I will have to connect device using USB cable and then test will run?

  15. Bas,

    I am trying to start android app testing using selendroid. I have placed file “selendroid-standalone-0.12.0-with-dependencies” in my D :[drive].

    Now I am trying to access in following way :

    java -jar selendroid-standalone-0.12.0-with-dependencies.jar -app selendroid-test-app-0.12.0.apk

    But it says “Unable to locate jar file selendroid-standalone-0.12.0-with-dependencies.jar

    I am on that path still why it is saying like this?

    • Hi Tester,

      let’s see if I get this correctly:
      – you put the selendroid jar file in the root of your D-drive
      – you also put the test app in the same location
      – you navigated to the root of the D-drive in your console
      – you entered the command that you posted

      Is that correct? If the java installation directory is correctly added to your class path, then it should work that way.. Could you post a screenshot for me?

      And are you on Windows, Linux or OSX? If you’re not on windows, you might want to try this instead:

      java -jar ./selendroid-standalone-0.12.0-with-dependencies.jar -app selendroid-test-app-0.12.0.apk

  16. Bas,

    Thank for reply. Now All issue solved. I have imported selenium jar and selendroid jar and created java project.

    But issue is AFTER write this line : SelendroidCapabilities capa = new SelendroidCapabilities(“io.selendroid.androiddriver:0.12.0”);

    When I write capa.(dot) , it is not populating methods.

    What I am missing?

  17. on localhost link I am getting below :

    {“value”:{“os”:{“name”:”Windows 7″,”arch”:”amd64″,”version”:”6.1″},”build”:{“browserName”:”selendroid”,”version”:”0.12.0″},”supportedDevices”:[{“emulator”:false,”screenSize”:”(720, 1280)”,”serial”:”192.168.56.102:5555″,”platformVersion”:”17″,”model”:”Samsung Galaxy S3 – 4.2.2 – API 17 – 720x1280_1″}],”supportedApps”:[{“mainActivity”:”io.selendroid.androiddriver.WebViewActivity”,”appId”:”io.selendroid.androiddriver:0.12.0″,”basePackage”:”io.selendroid.androiddriver”}]},”status”:0}

    I am not getting things like “androidTarget” ?

  18. BAS ,

    Please ignore all previous message , I have solved all. help for following :

    Now getting following :

    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:125)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:430)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:384)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
    at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
    at java.lang.Thread.run(Thread.java:856)

    • Good to hear you’ve managed to solve the previous issues. No idea where the current error message comes from, sounds like a networking issue (as netty.io is used for network communication). Is it a persistent error, i.e., does it occur all the time, or just once?

  19. Yes solved all previous error. app is opening . in code I have set user name and password box ids.

    But it says me :

    The element with id ‘520eb984-40c9-a797-f6f8-d0313b9ff269’ was not found. for user id.

    which format this is?

    • That’s a GUID or a Global Unique IDentifier, if that’s the ID of your element I strongly suggest using another way of identifying the element. It might be that this ID changes everytime the element is rendered (i.e., each time you run your test)..

      • Okay. another way means name? Please help me because in web we can use like xpath , cssselector , id , name , class. so what are options for app?

        • You can use the Selendroid Inspector (http://selendroid.io/inspector.html) to check the properties of the element and select an appropriate identification method in Selendroid. You can always use XPath as far as I know, but if the element has a unique name attribute, I’d suggest using that.

          Let me know whether that works for you.

    • Hmm.. I’ve never used the Inspector myself. I don’t know of any other solution to find element properties for mobile applications, so I guess you have to do as the instruction says..

      • Okay , I managed things. Now issue it program running fine when I debug , But when I RUN then it is not able to find elements. It just open app.

        so here what should I do? I have put WAIT but that is not working.. Please help.

  20. Bas,

    All error are solved and I able to run my selendroid program perfectly. But now not able to login and go inside app.

    I am running app. using selendroid. app opens , insert user name and password , click on signin button. Once I click then it close the app.

    In command line it shows : info: return value from selendroid android server – getting BLANK

    Any solution please?

    • Is this the demo app provided on the Selendroid site or another app?

      I haven’t worked with Selendroid for quite some time now (haven’t had the time) to be honest, so I’m a little out of the loop myself. If the app is starting correctly and you’re able to reach and interact with the login screen I’d say everything is fine as far as Selendroid goes.

  21. I am using my own app. not selendroid given default app. But when I tap on login then all data coming from web services so may I need to handle diff. thing to get web service response? Or need to handle any session after login?

    • Honestly, I have no idea how that is handled in your application..

      My common sense says that when it’s working if you login by hand (either on your mobile device or on an emulator) then it should be possible to do so using Selendroid as well.

  22. Bas ,

    I have just marked that I am not able to click on any button in my app using selenfroid , I am getting following when click on button :

    org.openqa.selenium.WebDriverException: The selendroid server on the device became unreachable.
    This most likely means the app under test crashed or has been killed by the OS in a way that can’t be detected using the default uncaught exception handler.
    Try to look for the reason of the crash in logcat.
    io.selendroid.exceptions.SelendroidException: The selendroid server on the device became unreachable.
    This most likely means the app under test crashed or has been killed by the OS in a way that can’t be detected using the default uncaught exception handler.
    Try to look for the reason of the crash in logcat.
    at io.selendroid.server.handler.RequestRedirectHandler.handle(RequestRedirectHandler.java:88)
    at io.selendroid.server.SelendroidServlet.handleRequest(SelendroidServlet.java:143)
    at io.selendroid.server.BaseServlet.handleHttpRequest(BaseServlet.java:67)
    at io.selendroid.server.http.ServerHandler.channelRead(ServerHandler.java:53)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
    at io.netty.handler.traffic.AbstractTrafficShapingHandler.channelRead(AbstractTrafficShapingHandler.java:223)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163)
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:148)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:125)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
    at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
    at java.lang.Thread.run(Unknown Source)

    Command duration or timeout: 744 milliseconds
    Build info: version: ‘unknown’, revision: ‘unknown’, time: ‘unknown’
    System info: host: ‘RangamQA01’, ip: ‘192.168.1.200’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_25’
    Driver info: io.selendroid.SelendroidDriver
    Capabilities [{emulator=false, aut=air.iNMyBabyPaid:1.3.0, serial=192.168.56.102:5555, platformVersion=17, automationName=selendroid, browserName=selendroid, platformName=android, platform=ANY}]
    Session ID: 6ac63d74-f71f-3404-fb22-2ef52fcacc8e

  23. When I use : System.out.println(driver.manage().logs());

    I am getting : org.openqa.selenium.remote.RemoteLogs@1eb5174b

    What it indicates?

  24. Silly question, but am I supposed to run the script as a JUnit test? I tried running it with both the Eclipse and Android JUnit launchers, but I always got an error message saying no tests were found.

    • Hi Danny,

      I just noticed that my post doesn’t make that too clear, so it’s not a silly question at all. You can pick either of these two options:

      1. Mark the method from the post as a JUnit method using the @Test annotation – make sure the JUnit library is on your classpath. Then run the class as a JUnit test.
      2. Create a main method (public static void main (String args[]) and call the runSelendroidTest() method from there. Then run the class as a regular Java application.

      Either option should work, just pick the one that best fits your framework and preferences.

    • Hi Naina,

      from my rather limited experience with both (I’m not into mobile test automation, at least not at the moment), I don’t think one is necessarily better than the other.

      Appium has a benefit in supporting many programming languages (Selendroid is Java only), though.

    • Naina ,

      Bas is right. Appium will give you more features , flexibility than selendroid.

      Also I think Selendroid is limited for android only where appium support Ios app testing also.

      • Thanks for your comment. As I’ve said, I don’t have any real experience in mobile test automation so I’m not up to speed on what are the best tools and so on.. That’s the main reason there’s only a single post on Selendroid on this site. It does get quite a few comments though 🙂

        Maybe when I’ll get to work with mobile test automation some more in the future I’ll be able to write some more posts on the subject, but to be honest I can’t see that happening soon.

  25. Pingback: 2014最受欢迎的开源 Android 测试工具 丨 朱少宁

  26. Bas,

    My selendroid program was working fine but now suddenly I am getting below error :

    selendroid-standalone-0.12.0-with-dependencies has no source attachment.

    can you please help me to solve it?

    • Did you change anything in your project setup? For example, did you add a new version of the Selendroid jar?

      Could you please retry with the latest Selendroid version (i.e., 0.15)?

      • No,

        I have changed nothing 🙁

        I tried with latest but not working.

        I have imported following JARs :

        java-client-2.1.0
        java-client-2.1.0-javadoc
        java-client-2.1.0-sources
        selendroid-client-0.10.0
        selendroid-client-0.10.0-javadoc
        selendroid-client-0.10.0-sources
        selendroid-standalone-0.12.0-with-dependencies
        selenium-java-2.44.0
        selenium-java-2.44.0-srcs
        selenium-server-standalone-2.44.0

        I have tried by debug also..:(

        • That’s a lot of imports.. I can’t remember having to import that many libraries. What happens when you remove everything except for selendroid-standalone-0.12.0-with-dependencies and selenium-server-standalone-2.44.0?

          I think java-client-2.1.0 is required only for Appium, not for Selendroid?

          • If I use those 2 files only then it is not able to allow me to initialize SelendroidDriver.

            Like :

            WebDriver driver = new SelendroidDriver(capa);

  27. My code is :

    SelendroidCapabilities capa = new SelendroidCapabilities(“air.iNMyBabyPaid:1.3.0”);

    capa.setSerial(“192.168.56.101:5555”);

    capa.setCapability(“platformVersion”, “16”);

    // explicitly state that we want to run our test on an Android API level 10 device
    // capa.setPlatformVersion(DeviceTargetPlatform.ANDROID17);

    // explicitly state that we use an emulator (an AVD) for test execution rather than a physical device
    capa.setEmulator(false);

    // start a new WebDriver
    WebDriver driver = new SelendroidDriver(capa);
    System.out.println(driver.getPageSource());

    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    // execute a very simple test

    WebElement username = driver.findElement(By.xpath(“(//EditText)[1]”));
    // Assert.assertEquals(“true”, username.getAttribute(“enabled”));

    username.click();

    username.sendKeys(“sparent”);

    WebElement pass = driver.findElement(By.xpath(“(//EditText)[2]”));
    // Assert.assertEquals(“true”, pass.getAttribute(“enabled”));
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    pass.click();

    pass.sendKeys(“test123@”);

    WebElement login = driver.findElement(By.xpath(“//LinearLayout[@id=’llSignIn’]”));
    // Assert.assertEquals(“true”, login.getAttribute(“enabled”));

    login.click();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    // quit testing
    driver.quit();

    }
    catch (Exception e)

    {

    e.printStackTrace();
    }

    }

    }

    I am using genymotion as emulator.

  28. Why do you do capa.setEmulator(false); when you use an emulator for your tests? Setting this to false would imply you’re running your tests against an actual device..

    I can’t reproduce your problem here as I don’t have an Android SDK installed here at work (nor do I want to). So all I can do for you is guess..

    • Yes , You are right. but selendroid consider Genymotion as actual device so we have to do this capa.setEmulator(false)…

      Its ok . let me try with some other way…

  29. Hi,

    I am new in selendroid and i am getting following error.

    The requested application under test is not configured in selendroid server.

    If you can help me to solve this.

    Thanks,
    Gunjan.

    • Hi Gunjan,

      from a quick Google search (I can’t access Selendroid where I am at the moment) :

      1) Have you started the selendroid server? This is done using

      java -jar selendroid-standalone-0.9.0-with-dependencies.jar -aut your-test.apk

      Also be sure to insert the correct SelendroidCapabilities in your code which you can get after starting the server from http://localhost:4444/wd/hub/status

      2) If that does not help and you’re using a real device (no emulation), then when you connect your device, in dos type “adb devices”…. see if your real device shows there. if not, then go to device manager and see if there is any problems with installing drivers for your device.

      e.g. right click on my computer and click manage and select device manager… look under other devices if there is any error or yellow exclamation mark.

      Also in your device you need to ensure usb debugging is enabled; go settings, developer tools and enable usb

      Hope that helps.

      • Hi Bas,

        I am getting following error when clicked on Login button from App,Actually once user is logged in, it is generated google token for user.Installed google play services in emulator but still facing following error….

        W/GooglePlayServicesUtil( 3591): Google Play services out of date. Requires 757
        1000 but found 6585038
        E/AndroidRuntime( 3591): FATAL EXCEPTION: main
        E/AndroidRuntime( 3591): Process: com.peddle.buyer, PID: 3591
        E/AndroidRuntime( 3591): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.test/com.test.test.TaskInformationActivity}: java.lang.NullPointerException

        If you can help me to solve this……..

      • Hi Bas,

        Again facing new issue.It seems that ‘Wait’ is not working in my script.

        1. Once click on ‘Log in’ button.Loading mask in displayed
        2. System fetch data from backend
        3. Once entire page is load
        4. Try to click on ‘Buy’ button

        but in my script log shows,at same time all the events are executed.

        In above script,added following lines after

        Script:

        WebElement pages3 = driver.findElement(By.id(“com.peddle.buyer:id/onBoardTopContainer”));
        TouchActions flick3 = new TouchActions(driver).flick(pages3, -100, 0, 0);
        flick3.perform();

        driver.findElement(By.linkText(“Get started”)).click();
        driver.findElement(By.linkText(“Log in with Peddle”)).click();

        WebElement Email = driver.findElement(By.id(“emailInputTextView”));
        Email.sendKeys(user.email);

        driver.findElement(By.id(“passwordInput”)).sendKeys(user.password);

        driver.findElement(By.linkText(“Log in”)).click();
        —————
        wait.until(ExpectedConditions.elementToBeClickable(By.id(“passButton”)));

        //driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);

        driver.findElement(By.id(“passButton”)).click();
        ————————–

        If you can please guide me….

        Thanks,

      • Hi All,

        For native apps,Is any way to select option from list view in selendroid?

        for example

        First Name
        Last Name
        City

        If any one help me to solve this….

        Thanks in advance…

      • Hi All,

        I am not able to load next slide in app using selendroid.

        Here is my script
        SelendroidCapabilities capa = new SelendroidCapabilities(“com.peddle.seller:1.43”);
        driver = new SelendroidDriver(capa); capa.setCapability(“app-activity”, “com.peddle.seller.SplashActivity”);
        capa.setCapability(“app-wait-activity”, “com.peddle.seller.SellerHomeActivity”);
        //driver.get(“and-activity://com.peddle.seller.SellerHomeActivity”);

        WebDriverWait wait = new WebDriverWait(driver, 60);
        wait.until(ExpectedConditions.presenceOfElementLocated(By.id(“heroGetYourOfferButton”)));
        driver.findElement(By.linkText(“Get your offer”)).click();
        wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText(“2012”))).click();
        wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText(“Acura”))).click();
        wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText(“MDX”))).click();
        wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText(“Base”))).click();

        TimeUnit.SECONDS.sleep(5);
        wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText(“I have clean title.”))).click();

        once trim is selected (Base) app is force closed.

        Here is selendroid error log

        W/ActivityManager( 294): Error in app com.peddle.seller running instrumentation
        ComponentInfo{io.selendroid.com.peddle.seller/io.selendroid.ServerInstrumentati
        on}:
        W/ActivityManager( 294): java.lang.IllegalAccessError
        W/ActivityManager( 294): java.lang.IllegalAccessError: Class ref in pre-verif
        ied class resolved to unexpected implementation
        I/ActivityManager( 294): Force stopping package com.peddle.seller appid=10047 u
        ser=0
        I/ActivityManager( 294): Killing proc 934:com.peddle.seller/u0a10047: force sto
        p com.peddle.seller
        W/ActivityManager( 294): Force removing ActivityRecord{41223548 u0 com.peddle.s
        eller/.VehicleInfoActivity}: app died, no saved state
        I/WindowState( 294): WIN DEATH: Window{40f6b588 u0 com.peddle.seller/com.peddle
        .seller.VehicleInfoActivity}
        Jun 26, 2015 4:06:10 PM io.selendroid.SelendroidLauncher$1 run
        INFO: Shutting down Selendroid standalone

        Please help me to solve this…….It’s urget please….

  30. Thanks for your halp!!!.It is working now…

    1 more question

    How to write wait command in Selendroid? Which is good either Implicitly or Thread.sleep

    Because my application take some time to get data.

    Tried with following driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    but it seems that next slide is not loaded and my application is closed.

    If you can help me to solve this……Please…..

    Thanks in Advance!!!

    Thanks,
    Gunjan.

      • Hi, my application is not slow but application fetch data from back end.so, once clicked on login button,loading mask is appeared and once data loads,next slide is displayed. Please help to solve this.should I use for loop or any other option. Please suggest.

        Thanks,
        Gunjan

  31. Hi Bas,

    I am getting following error in selendroid and my app is crashed, Once user clicked on Login button from App,It is generated google token.Also, Installed google play services in emulator but still facing the error.

    W/GooglePlayServicesUtil( 3591): Google Play services out of date. Requires 757
    1000 but found 6585038
    E/AndroidRuntime( 3591): FATAL EXCEPTION: main
    E/AndroidRuntime( 3591): Process: com.peddle.buyer, PID: 3591
    E/AndroidRuntime( 3591): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.peddle.buyer/com.peddle.buyer.TaskInformationActivity}: java.lan
    g.NullPointerExceptio

    If you can help me to solve this….

  32. Hi Bas,

    Again i am getting new error.Once clicked on ‘Login’ button my app is crashed and following is error

    Error:
    E/AndroidRuntime( 1190): FATAL EXCEPTION: main
    E/AndroidRuntime( 1190): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.peddle.buyer/com.peddle.buer.TaskInformationActivity}: java.lang.NullPointerException

    If you can help me!!!

    • Could you post the code to your activity and the complete stack trace or at least the line number where the NullPointerException occurs within your activity?

  33. Here is my script.

    package com.peddlebuyer.test;

    import java.net.URL;

    import io.selendroid.SelendroidCapabilities;
    import io.selendroid.SelendroidConfiguration;
    import io.selendroid.SelendroidDriver;
    import io.selendroid.SelendroidLauncher;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;
    import org.openqa.selenium.remote.Response;
    import org.testng.Assert;
    import org.testng.annotations.AfterSuite;
    import org.testng.annotations.BeforeSuite;
    import org.testng.annotations.Test;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.interactions.Action;
    import org.openqa.selenium.interactions.touch.FlickAction;
    import org.openqa.selenium.interactions.touch.TouchActions;

    import org.testng.annotations.Test;
    import org.testng.annotations.BeforeMethod;
    import org.testng.annotations.AfterMethod;

    import java.util.concurrent.TimeUnit;
    import java.util.logging.ConsoleHandler;

    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;
    import io.selendroid.waiter.TestWaiter;
    import io.selendroid.waiter.WaitingConditions;

    public class PeddleBuyer {
    private WebDriver driver = null;

    @BeforeMethod
    public void beforeMethod() throws Exception {

    }

    @Test
    public void assertSellerCanLogin() {

    UserDO user = new UserDO(“nilofar.jargela@marutitech.com”,”123456″);
    try {
    loginUser(user);
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }

    private void loginUser(UserDO user) throws Exception {

    SelendroidCapabilities capa = new SelendroidCapabilities(“com.peddle.buyer:1.31”);
    driver = new SelendroidDriver(capa);
    capa.setCapability(“app-activity”, “com.peddle.buyer.SplashActivity”);
    capa.setCapability(“app-wait-activity”, “com.peddle.buyer.BuyerHomeActivity”);

    driver.get(“and-activity://com.peddle.buyer.BuyerHomeActivity”);

    WebDriverWait wait = new WebDriverWait(driver, 60);
    wait.until(ExpectedConditions.presenceOfElementLocated(By.id(“onBoardTopContainer”)));
    WebElement pages1 = driver.findElement(By.id(“com.peddle.buyer:id/onBoardTopContainer”));
    TouchActions flick1 = new TouchActions(driver).flick(pages1, -100, 0, 0);
    flick1.perform();

    WebElement pages2 = driver.findElement(By.id(“com.peddle.buyer:id/onBoardTopContainer”));
    TouchActions flick2 = new TouchActions(driver).flick(pages2, -100, 0, 0);
    flick2.perform();

    WebElement pages3 = driver.findElement(By.id(“com.peddle.buyer:id/onBoardTopContainer”));
    TouchActions flick3 = new TouchActions(driver).flick(pages3, -100, 0, 0);
    flick3.perform();

    driver.findElement(By.linkText(“Get started”)).click();
    driver.findElement(By.linkText(“Log in with Peddle”)).click();

    WebElement Email = driver.findElement(By.id(“emailInputTextView”));
    Email.sendKeys(user.email);

    driver.findElement(By.id(“passwordInput”)).sendKeys(user.password);

    driver.findElement(By.linkText(“Log in”)).click();

    Here is my UserDO script

    package com.peddlebuyer.test;

    public class UserDO {

    public String email;
    public String password;

    public UserDO(String email, String password) {
    super();
    this.email = email;
    this.password = password;

    }

    }

    //WebDriverWait wait = new WebDriverWait(driver, 60);
    //wait.until(ExpectedConditions.presenceOfElementLocated(By.id(“taskIdText”)));
    // wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText(“Buy”)));
    // wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText(“Pass”)));
    //wait.until(ExpectedConditions.presenceOfElementLocated(By.id(“taskThumbImage”)));
    // wait.until(ExpectedConditions.presenceOfElementLocated(By.id(“infoButton”)));
    // wait.until(ExpectedConditions.presenceOfElementLocated(By.id(“footerShadowLayout”)));

    capa.setCapability(“app-activity”, “com.peddle.buyer.BuyerHomeActivity”);
    capa.setCapability(“app-wait-activity”, “com.peddle.buyer.TaskInformationActivity”);
    driver.get(“and-activity://com.peddle.buyer.TaskInformationActivity”);

    }

    @AfterMethod
    public void afterMethod() {
    //driver.quit();
    }

    }

    • I assume the NullPointerException occurs on this line?

      driver.get(“and-activity://com.peddle.buyer.TaskInformationActivity”);

      Another tip: why do you have an empty @BeforeMethod and why do you set up your driver object in your test method? It’s common practice to do the setup in your @BeforeMethod so you only have to do this once for your entire test suite. Reduces the number of code lines to be used as well..

  34. Here is my UserDO script

    package com.peddlebuyer.test;

    public class UserDO {

    public String email;
    public String password;

    public UserDO(String email, String password) {
    super();
    this.email = email;
    this.password = password;

    }

    }

  35. Hi Bas,

    Again facing new issue.It seems that ‘Wait’ is not working in my script.

    1. Once click on ‘Log in’ button.Loading mask in displayed
    2. System fetch data from backend
    3. Once entire page is load
    4. Try to click on ‘Buy’ button

    but in my script log shows,at same time all the events are executed.

    In above script,added following lines after login

    Script:

    WebElement pages3 = driver.findElement(By.id(“com.peddle.buyer:id/onBoardTopContainer”));
    TouchActions flick3 = new TouchActions(driver).flick(pages3, -100, 0, 0);
    flick3.perform();

    driver.findElement(By.linkText(“Get started”)).click();
    driver.findElement(By.linkText(“Log in with Peddle”)).click();

    WebElement Email = driver.findElement(By.id(“emailInputTextView”));
    Email.sendKeys(user.email);

    driver.findElement(By.id(“passwordInput”)).sendKeys(user.password);

    driver.findElement(By.linkText(“Log in”)).click();
    —————
    wait.until(ExpectedConditions.elementToBeClickable(By.id(“passButton”)));

    //driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);

    driver.findElement(By.id(“passButton”)).click();
    ————————–

    If you can please guide me….

    Thanks,

    • I take it the button with id ‘passButton’ is your Buy button? What happens if you use the implicit wait you commented out?

      • No,Actually there are 2 buttons 1. Buy and 2. Pass.Once script is executed,Implicit wait is not working and button (passButton) during page load.

        But if i used Thread.sleep() it is working.But as per your suggestion ‘Never ever use Thread.sleep()…..’

        Added Thread.sleep in script and it is working

        driver.findElement(By.linkText(“Log in”)).click();

        wait.until(ExpectedConditions.elementToBeClickable(By.id(“passButton”)));

        Thread.sleep(10000);
        //driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

        driver.findElement(By.id(“passButton”)).click();

        }

        But i don’t want to use this(Thread.sleep()) If you can please help me…..

  36. Hi Bas,

    Here is my script and added thread.sleep() many times in script.If you can suggest another option i am not getting any error if i used implicit or explicit wait but once i used implicit wait.It is does not wait and pass button even is executed during page load.

    driver.findElement(By.linkText(“Log in”)).click();

    wait.until(ExpectedConditions.elementToBeClickable(By.id(“passButton”)));

    Thread.sleep(10000);
    //driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

    driver.findElement(By.id(“passButton”)).click();

    Thread.sleep(10000);
    //driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

    driver.findElement(By.id(“buyButton”)).click();

    Thread.sleep(10000);
    //driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

    driver.findElement(By.id(“yesButton”)).click();

    Thread.sleep(5000);
    //driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

    driver.findElement(By.id(“alertOkButton”)).click();

    }

    @AfterMethod
    public void afterMethod() {
    //driver.quit();
    }

    }

    • Hi Pooja,

      I don’t know whether it is the source of your problem, but you don’t need to insert the line

      driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

      for every WebElement you’re looking for. You just need to do this once when you instantiate your driver object.

      Having said that, I don’t know why your implicit waits do not work. Google gives quite a few hits when you search for ‘Selendroid implicit wait’, maybe those results will help you further.. I stand by my opinion that Thread.sleep() should be avoided at all times!

  37. Hi Bas,

    When i ran above script (Whole script is available in previous comment) with implicit wait. I am getting error

    INFO: POST redirect to: http://localhost:8080/wd/hub/session/f795f003-0a72-c4b8-
    f022-0331f2e67856/element
    Jun 19, 2015 6:32:09 PM io.selendroid.server.handler.RequestRedirectHandler redi
    rectRequest
    INFO: Payload? {“using”:”id”,”value”:”passButton”}
    Jun 19, 2015 6:32:14 PM io.selendroid.server.handler.RequestRedirectHandler hand
    le
    INFO: return value from selendroid android server: {“message”:”Element was not f
    ound.\nio.selendroid.exceptions.NoSuchElementException: Element was not found.\n
    \tat io.selendroid.server.handler.FindElement.ha…
    Jun 19, 2015 6:32:15 PM io.selendroid.server.handler.RequestRedirectHandler handle

    Let me know how can i solve this?

    • Hi Pooja,
      Can you tell us how are finding the element:
      Is it using id or xpath?
      NoSuchElementException usually comes when there is an id conflict (2 or more elements with same id).
      Try using alternative like xpath, link or partial link.
      Please share the concerned code if possible.

      • Hi Vikram,

        Thanks for reply. Here is my script code.

        driver.findElement(By.linkText(“Log in”)).click();

        driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

        driver.findElement(By.id(“passButton”)).click();

  38. Hi All,

    For native app, Is any way to select single option from List view?

    For example
    Firstname
    Lastname

    If any one help me to solve this….

    Thanks in advance…

    • Hi All,

      For native app, Is any way to select single option from List view in selendroid?

      For example
      Firstname
      Lastname

      If any one help me to solve this….

      Thanks in advance…

  39. Hi All,

    Not able to load next slide in app using selendroid.

    Here is my script

    SelendroidCapabilities capa = new SelendroidCapabilities(“com.peddle.seller:1.43”);
    driver = new SelendroidDriver(capa);
    capa.setCapability(“app-activity”, “com.peddle.seller.SplashActivity”);
    capa.setCapability(“app-wait-activity”, “com.peddle.seller.SellerHomeActivity”);
    //driver.get(“and-activity://com.peddle.seller.SellerHomeActivity”);

    WebDriverWait wait = new WebDriverWait(driver, 60);
    wait.until(ExpectedConditions.presenceOfElementLocated(By.id(“heroGetYourOfferButton”)));
    driver.findElement(By.linkText(“Get your offer”)).click();
    wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText(“2012”))).click();
    wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText(“Acura”))).click();
    wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText(“MDX”))).click();
    wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText(“Base”))).click();
    TimeUnit.SECONDS.sleep(5);
    wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText(“I have clean title.”))).click();

    Once trim is selected (Base) then app is crash.Next slide is not loaded.

    Here is selendroid server error log:

    W/ActivityManager( 294): Error in app com.peddle.seller running instrumentation
    ComponentInfo{io.selendroid.com.peddle.seller/io.selendroid.ServerInstrumentati
    on}:
    W/ActivityManager( 294): java.lang.IllegalAccessError
    W/ActivityManager( 294): java.lang.IllegalAccessError: Class ref in pre-verif
    ied class resolved to unexpected implementation
    I/ActivityManager( 294): Force stopping package com.peddle.seller appid=10047 u
    ser=0
    I/ActivityManager( 294): Killing proc 934:com.peddle.seller/u0a10047: force sto
    p com.peddle.seller
    W/ActivityManager( 294): Force removing ActivityRecord{41223548 u0 com.peddle.s
    eller/.VehicleInfoActivity}: app died, no saved state
    I/WindowState( 294): WIN DEATH: Window{40f6b588 u0 com.peddle.seller/com.peddle
    .seller.VehicleInfoActivity}
    Jun 26, 2015 4:06:10 PM io.selendroid.SelendroidLauncher$1 run
    INFO: Shutting down Selendroid standalone

    If anyone help me…It is urgent Please……………

    Thanks in advance.

  40. Pingback: 2014 非常好用的开源 Android 测试工具 | 技术联盟

  41. Hi!

    I have a problem with selendroid on my ubuntu laptop. I have no idea what is wrong. On my other computer everything works fine.

    Error i get is:

    INFO: Removing: HardwareDevice [serial=LGD722cb9c17c2, model=LG-D722, targetVersion=ANDROID21, apiTargetType=google]
    Exception in thread “Thread-73” org.openqa.selenium.WebDriverException: io.selendroid.server.common.exceptions.SelendroidException: The test session has been marked as invalid. This happens if a hardware device was disconnected but a test session was still active on the device.
    at io.selendroid.standalone.server.handler.ProxyToDeviceHandler.handleRequest(ProxyToDeviceHandler.java:70)
    at io.selendroid.standalone.server.BaseSelendroidStandaloneHandler.handle(BaseSelendroidStandaloneHandler.java:45)
    at io.selendroid.standalone.server.SelendroidServlet.handleRequest(SelendroidServlet.java:131)
    at io.selendroid.server.common.BaseServlet.handleHttpRequest(BaseServlet.java:67)
    at io.selendroid.server.common.http.ServerHandler.channelRead(ServerHandler.java:53)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
    at io.netty.handler.traffic.AbstractTrafficShapingHandler.channelRead(AbstractTrafficShapingHandler.java:223)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163)
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:148)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:125)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
    at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
    at java.lang.Thread.run(Thread.java:745)

    Then i get:

    01:55:30 E/DeviceMonitor: Adb connection Error:EOF
    01:55:30 E/DeviceMonitor: Connection attempts: 1

    connection with phone is still restarting.

    This appears when the app is opened. Installing app and Selendroid on my phone goes well. I try to adb kill-server and start-server.

    Have no idea what is wrong.

  42. Hi ,
    Basically i am new to selendroid.
    i just wanted to know that, for using selendroid script which jar files we should import and also please tell me the versions of jar files which are internally associated with each other. Because when i am running the script it is giving the error “The type org.openqa.selenium.HasTouchScreen cannot be resolved. It is indirectly referenced from required .class files”

    Please Help..
    Thanks in advance.

  43. Hi. I’m stuck with this issue.

    SelendroidCapabilities capa = new SelendroidCapabilities(“io.selendroid.testapp:0.17.0”);
    WebDriver driver = new SelendroidDriver(capa);

    The constructor SelendroidDriver(SelendroidCapabilities) is undefined.

    Have no idea what is wrong.

    • Hi Macy,

      is the SelendroidDriver class recognized at all? If not, you might have to fix your dependencies. If so, you are using the wrong constructor (although it looks right to me). I couldn’t find API docs for Selendroid 0.17.0, so I can’t check it myself.. I’ll try some other way.

      • My code looks like this which I also copied from other tutorials… I have added the jar files on the project and still can’t find my way around… I changed it from WebDriver driver = new SelendroidDriver(capa); to WebDriver driver = new SelendroidDriver(null, capa);

        public class SelendroidTestApp {

        private WebDriver driver ;

        @BeforeSuite
        public void setUp() throws Exception
        {
        SelendroidConfiguration config = new SelendroidConfiguration();
        config.addSupportedApp(“selendroid-test-app-0.17.0.apk”);
        SelendroidLauncher selendroidServer = new SelendroidLauncher(config);
        selendroidServer.launchSelendroid();

        SelendroidCapabilities capa = new SelendroidCapabilities(“io.selendroid.testapp:0.17.0”);
        WebDriver driver = new SelendroidDriver(null, capa);
        }

        @Test
        public void selendroidTest() throws Exception
        {
        WebElement inputField = driver.findElement(By.id(“my_text_field”));
        AssertJUnit.assertEquals(“true”, inputField.getAttribute(“enabled”));
        inputField.sendKeys(“Selendroid”);

        AssertJUnit.assertEquals(“Selendroid”, inputField.getText());

        WebElement button = driver.findElement(By.id(“buttonTest”));
        button.click();

        }

        @AfterMethod @AfterSuite
        public void tearDown(){
        driver.quit();
        }

        }

        But I get this error..

        FAILED CONFIGURATION: @BeforeSuite setUp
        java.net.MalformedURLException
        at java.net.URL.(Unknown Source)
        at java.net.URL.(Unknown Source)
        at java.net.URL.(Unknown Source)
        at io.selendroid.SelendroidDriver.(SelendroidDriver.java:39)
        at SelendroidTestApp.setUp(SelendroidTestApp.java:34)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
        at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
        at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
        at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:277)
        at org.testng.SuiteRunner.run(SuiteRunner.java:240)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
        at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
        at org.testng.TestNG.run(TestNG.java:1057)
        at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
        at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
        Caused by: java.lang.NullPointerException
        … 23 more

        I’d really appreciate if you can help me with this and let me run my first Selendroid test. Also, thank you for the reply! 🙂

          • I changed it to WebDriver driver = new SelendroidDriver(“http://localhost:4444/wd/hub/status”, capa);

            I start the server on commandline using java -jar selendroid-standalone-0.16.0-with-dependencies.jar -aut selendroid-test-app-0.17.0.apk -port 5555

            What is displayed on command line is that the standalone server is running on port 5555 but on eclipse it displays the following error…
            Dec 11, 2015 3:29:50 PM io.selendroid.standalone.server.SelendroidStandaloneServer start
            INFO: Selendroid standalone server has been started on port: 4444
            FAILED CONFIGURATION: @BeforeSuite setUp
            org.openqa.selenium.UnsupportedCommandException: Build info: version: ‘unknown’, revision: ‘unknown’, time: ‘unknown’
            System info: host: ‘********’, ip: ‘172.**.*.***’, os.name: ‘Windows 8.1’, os.arch: ‘amd64’, os.version: ‘6.3’, java.version: ‘1.8.0_51’
            Driver info: io.selendroid.SelendroidDriver
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
            at java.lang.reflect.Constructor.newInstance(Unknown Source)
            at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
            at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
            at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
            at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
            at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
            at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
            at io.selendroid.SelendroidDriver.(SelendroidDriver.java:39)
            at SelendroidTestApp.setUp(SelendroidTestApp.java:34)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
            at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
            at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
            at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
            at org.testng.SuiteRunner.privateRun(SuiteRunner.java:277)
            at org.testng.SuiteRunner.run(SuiteRunner.java:240)
            at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
            at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
            at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
            at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
            at org.testng.TestNG.run(TestNG.java:1057)
            at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
            at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
            at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

            I am running the server on port 5555 because if I run it on port 4444 i get an error that says Exception in thread “Thread-46” java.net.BindException: Address already in use: bind…

            Thank u again for the reply. 🙂

          • I think (it’s been a long while since I’ve done anything with Selendroid or mobile testing in general, so forgive me) that you should change 4444 to 5555 in the constructor for the SelendroidDriver as well then.

    • Sorry I couldn’t help you out. I’d like to get more experience with mobile testing under my belt, but as you know.. So many things, so little time.. Please let us know here if you find a solution, you never know who you can help with it.

  44. Hi,

    I get java.lang.NullPointerExceptiion every time I try to run the below code thoug webElementid exists

    import junit.framework.Assert;
    import io.selendroid.client.SelendroidDriver;
    import io.selendroid.common.SelendroidCapabilities;

    import org.junit.Before;
    import org.junit.Test;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;

    public class Demo {

    WebDriver driver;

    @Test
    public void openApp() throws Exception
    {

    SelendroidCapabilities cap=new SelendroidCapabilities(“com.guru99app:1.0”);
    driver=new SelendroidDriver(cap);
    Thread.sleep(5000);

    }

    @Test
    public void selendroidTest() throws Exception {

    // Print the log
    System.out.print(“Start executing test”);

    // Find the input text field on screen
    // The id of this text field was get from step 9
    WebElement inputField = driver.findElement(By.id(“edtText”));

    // Verify that the text field enabled so user can enter text
    Assert.assertEquals(“true”, inputField.getAttribute(“enabled”));

    // Enter a text to text field
    inputField.sendKeys(“Hello Guru”);

    WebElement button = driver.findElement(By.id(“btnShow”));
    button.click();

    // Delay time to take effect
    Thread.sleep(5000);

    //Find the label “Text Show Here” on screen
    // The id of this label was get from step 9
    WebElement txtView = driver.findElement(By.id(“txtView”));

    //Get the text display on screen
    String expected = txtView.getText();

    // Verify that the text which user enter on text field is same as text display on screen
    Assert.assertEquals(expected, inputField.getText());

    }
    }

    • Hey Manasa,

      A couple of quick questions:

      what line in your code is returning that NullPointerException? Is it this one?

      WebElement inputField = driver.findElement(By.id(“edtText”));

      Can you tell me whether the app you want to test is starting correctly?

      What do you see in the console when you add this line before the one I mentioned?

      System.out.println(“Number of elements found: ” + driver.findElements(By.id(“edtText”)).size());

    • Hi Nha,

      I use Antagonist for my website hosting. They are fantastic, but unfortunately for the rest of the world they’re Dutch though and I’m not sure whether they operate worldwide.

  45. I just like the helpful info you supply on your articles.
    I will bookmark your weblog and check again right here regularly.
    I’m moderately sure I will be informed a lot of new stuff right here!
    Best of luck for the following!

  46. Pingback: 开源 Android 测试工具 – E4rljia's Blog

  47. Hi, I am using Selendroid to automate the app. but i am facing some problem ….its showing an error on terminal,

    An error occurred while resigning the app ‘selendroid-test-app- 0.17.0.apk’

    please give me the solution on that error…….

    • A quick Google search tells me that it’s probably due to the fact that your JAVA_HOME is pointing to a JRE and not to a JDK. Selendroid requires a JDK, minimum 1.6.

  48. Hi

    When i try to debug my java project as testNG to start the session.but debugging got this error “removing device manager listener from adb” then ” Adb connection Error:An existing connection was forcibly closed by the remote host”

    Here’s my code
    package com.guru.test;

    import java.net.MalformedURLException;
    import java.net.URL;

    import org.junit.Before;
    import org.junit.Test;
    import org.openqa.selenium.WebDriver;
    import org.testng.annotations.AfterSuite;
    import org.testng.annotations.BeforeClass;
    import org.testng.annotations.BeforeMethod;
    import org.testng.annotations.BeforeSuite;
    import org.testng.annotations.BeforeTest;

    import io.selendroid.SelendroidDriver;
    import io.selendroid.common.SelendroidCapabilities;
    import io.selendroid.common.device.DeviceTargetPlatform;
    import io.selendroid.standalone.SelendroidConfiguration;
    import io.selendroid.standalone.SelendroidLauncher;

    public class Guru99 {
    WebDriver driver;

    @BeforeTest
    public void setUps() throws MalformedURLException, Exception {

    //Start selendroid-standalone during test
    SelendroidConfiguration config = new SelendroidConfiguration();

    // Add the selendroid-test-app to the standalone server
    config.addSupportedApp(“selendroid-test-app-0.17.0.apk”);

    //start the standalone server
    SelendroidLauncher selendroidServer = new SelendroidLauncher(config);
    selendroidServer.launchSelendroid();

    // Create the selendroid capabilities
    SelendroidCapabilities capa = new SelendroidCapabilities(“io.selendroid.testapp:0.17.0”);

    // Specify to use selendroid’s test app

    // Specify to use the Android device API 19
    capa.setPlatformVersion(DeviceTargetPlatform.ANDROID17);

    // Don’t request simulator, use real device

    capa.setEmulator(false);
    //capa.wait(10000000);

    // Create instance of Selendroid Driver
    driver = new SelendroidDriver(new URL(“http://localhost:4444/wd/hub”),capa);

    }
    @Test
    public void MainTest(){
    System.out.print(“dada”);
    }

    @AfterSuite
    public void tearDown() throws Exception{
    driver.quit();
    }

    }

  49. Hi,
    I am new to this Selendroid.
    I have set up everything as per the instructions.

    But i am not able to create SelendroidDriver object.

    WebDriver driver = new SelendroidWebDriver(cap);;

  50. Pingback: 2014 非常好用的开源 Android 测试工具 – 阿斯达

  51. Dear

    I am facing the following issue while running test.

    FAILED CONFIGURATION: @BeforeSuite setUp
    java.lang.NoSuchMethodError: org.openqa.selenium.remote.CommandInfo.(Ljava/lang/String;Lorg/openqa/selenium/remote/HttpVerb;)V

    at io.selendroid.SelendroidCommandExecutor$1.(SelendroidCommandExecutor.java:31)
    at io.selendroid.SelendroidCommandExecutor.(SelendroidCommandExecutor.java:27)
    at io.selendroid.SelendroidDriver.(SelendroidDriver.java:70)
    at SelendroidTest.setUp(SelendroidTest.java:41)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:277)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)

  52. I am new in selendroid ,when I run it I have this error in console :
    Adb connection Error:An existing connection was forcibly closed by the remote host
    [2017-02-14 11:24:03 – DeviceMonitor] Connection attempts: 1
    [2017-02-14 11:24:05 – DeviceMonitor] Connection attempts: 2
    [2017-02-14 11:24:07 – DeviceMonitor] Connection attempts: 3
    [2017-02-14 11:24:09 – DeviceMonitor] Connection attempts: 4
    [2017-02-14 11:24:11 – DeviceMonitor] Connection attempts: 5
    [2017-02-14 11:24:13 – DeviceMonitor] Connection attempts: 6
    [2017-02-14 11:24:15 – DeviceMonitor] Connection attempts: 7
    [2017-02-14 11:24:17 – DeviceMonitor] Connection attempts: 8
    [2017-02-14 11:24:19 – DeviceMonitor] Connection attempts: 9
    [2017-02-14 11:24:21 – DeviceMonitor] Connection attempts: 10
    [2017-02-14 11:24:23 – DeviceMonitor] Connection attempts: 11

    • Hey Magda,

      I’m sorry but I have no idea. There seem to be a couple of hits on this error on StackOverflow, maybe you can find the answer there? Good luck!

    • Hey Gulshan,

      it’s been a long time since I’ve done anything related to mobile, so I’m probably not the right person to ask..

Leave a Reply

Your email address will not be published. Required fields are marked *