Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20



Use Selendroid to Test Mobile Web Application on Mobile Device

To assure the quality of mobile web application, we need to test mobile web application on real mobile devices instead of testing it on mobile emulator. This example teaches you how to test mobile web application on android mobile device. 

In this article, we use Ebay mobile site as a test application.  To identify web elements, please read the article titled "How to Identify Mobile Web Application Elements for Selendroid" . 

Test Case

Verify that users are able to search merchandise on Ebay mobile web site.

Test Step

Step 1: navigate to

Step 2: type in android in the search box

Step 3: click on search button or press enter.

Step 4: assert that the website returns number of android merchandises.

Automation Test Implementation

Step 1: create a Java project named "SeleniumMasterMobileTest", add a package named "com.seleniummaster.mobiletest", and add a JUnit test class named "". Make sure that in the build path, you referenced all required libraries as well as the Selendroid web driver library "selendroid-standalone-0.9.0-SNAPSHOT-with-dependencies.jar". 


Step 2: write the following code in the class.

package com.seleniummaster.mobiletest;

import static org.junit.Assert.*;
import io.selendroid.SelendroidCapabilities;
import io.selendroid.SelendroidConfiguration;
import io.selendroid.SelendroidDriver;
import io.selendroid.SelendroidLauncher;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class MobileWebTesteBayMobile {
  private SelendroidLauncher selendroidServer = null;
  private WebDriver driver = null;
  public void ShouldLogin() throws InterruptedException {
    //enter items to search
      //click enter button
      //assert the Search Count text has the word results 
      for (int second = 0;; second++) {
        if (second >= 60fail("timeout");
        try if (isElementPresent("SearchCount"))) breakcatch (Exception e) {}

  private boolean isElementPresent(By by) {
      try {
        return true;
      catch (NoSuchElementException e) {
        return false;

  public void startSelendroidServer() throws Exception {
    if (selendroidServer != null) {
    SelendroidConfiguration config = new SelendroidConfiguration();

    selendroidServer = new SelendroidLauncher(config);

    DesiredCapabilities caps =;

    driver = new SelendroidDriver(caps);
 // Thread.sleep(50000);

  public void stopSelendroidServer() {
    if (driver != null) {
    if (selendroidServer != null) {

Step 3: attach any android device to the computer and make sure that you unlock the device before start the JUnit test

Step 4: run the test as JUnit test and verify the result. 

The above result indicated that Ebay mobile web test passed. 

Watch the video below to check the test on Android Mobile device