Create Appium script on android mobile web

In this post, we are going to explain you the Appium script for android’s chrome browser. In our previous post, we have covered the installation and configuration part that you have to do before executing Appium script. You can read that post from this link.

First of all, create a new project in Eclipse and include following mentioned jars in your project.


    • Add Google Play Store on Genymotion emulator so that you can install applications available on play store. As of now, just install chrome browser. Refer this video.
    • Appium server should be started.


    • Emulator should be connected and opened.



Here is the scenario that we are going to cover :

1. Launch chrome browser on Genymotion emulator and then open into it.
2. Enter invalid username and password
3. Print error message
4. Close browser.

import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class FacebookTest {

    WebDriver driver;

     public void setupstart() throws MalformedURLException
            DesiredCapabilities capabilities =;
            capabilities.setCapability("automationName", "Appium");
            capabilities.setCapability("platformName", "Android");
            capabilities.setCapability("deviceName", "");
            capabilities.setCapability("browserName", "Chrome");

            driver = new RemoteWebDriver(new URL(""), capabilities);
            driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

    public void testApp() throws InterruptedException {

        //Entering username

        //Entering passsword

        //clicking on login button

        //Print error message


    public void tearDown() {
        //closing browser


In the above program, desired capabilities are mentioned which helps Appium to understand that which browser it has to invoke and on which device etc.
Desired capabilities are basically a set of keys and values which goes to the Appium server to tell that what kind of automation session user interested in starting up. There are various capabilities which can modify the behavior of the server during automation. You can refer the server capabilities from Appium Doc.

Below We have explained the Appium server capabilities that have been used in our script.

1. Automaton name is Appium

capabilities.setCapability("automationName", "Appium");

2. As we have created this script for android, so we have to tell Appium about the platform where we actually want to run our scrpt. For Iphone, it would be iOS.

capabilities.setCapability("platformName", "Android");

3. We have to tell the Device name to Appium server so that it could recognize the device before launching the browser. You will get this ID after running the “adb devices” command. To know more about how to run this command. Refer our previous post.

capabilities.setCapability("deviceName", "");

4. As we want to open chrome browser on android, so we have mentioned browser name as chrome.

capabilities.setCapability("browserName", "Chrome");

5. Here, we have to provide the IP address and port number that we have used while starting the Appium server

driver = new RemoteWebDriver(new URL(""), capabilities);

If you really like the information provided above, please don’t forget to leave the comment. You can also like us on Facebook.

Comments are closed.