Appium Tutorial - Type In Text Box Of Android App

Text box is very common element of any android native software app or software web application. In android appium software automation test, If you wants to type text in text box of android app then you can use sendKeys(keysToSend) command of selenium WebElement interface. Let's look at example to learn how to type in text box of android app.

App To Use And Aim Of Test
We will use API Demos software app in this test to learn how to type in textbox of android application. 

appium - type in text box of android app

Above screen display text box. We will use this text box to type text in android appium software test. You can navigate to above screen from API Demos app's Home -> Views -> Controls -> 2. Dark Theme.

Create and run software test
Create bellow given test in eclipse and run it using testng and appium and observe test execution in your android mobile screen.
package Android;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class TypeInTextBox {
 AndroidDriver driver;

 public void setUp() throws Exception {
  DesiredCapabilities capabilities = new DesiredCapabilities();
  capabilities.setCapability("deviceName", "ZX1B32FFXF");
  capabilities.setCapability("browserName", "Android");
  capabilities.setCapability("platformVersion", "4.4.2");
  capabilities.setCapability("platformName", "Android");
  capabilities.setCapability("appPackage", "");
  driver = new AndroidDriver(new URL(""), capabilities);
  driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

 public void typeInText() throws InterruptedException {
  // Scroll till element which contains "Views" text If It Is not visible on screen.
  // Click on Views.
  // Scroll till element which contains "Controls" text If It Is not visible on screen.
  // Click on Controls.
  // Scroll till element which contains "2. Dark Theme" text If It Is not visible on screen.
  driver.scrollTo("2. Dark Theme");
  // Click on 2. Dark Theme.
  driver.findElement("2. Dark Theme")).click();
  // Typing in text box using sendKeys command.

 public void End() {

Last statement of text method will type text "Test" in textbox of API Demos android app.

This way you can use sendKeys(keysToSend) command to type text in any text box of android software  application.


  1. some times sendkeys() is not working.... is there any other mmethod

  2. i tried sendKeys() and setValue() but i get an error.