Appium Tutorials - Retrieve Drop Down Values List Of Android App

Retrieving all values from drop down list of android app software in appium software automation test is little tricky task but not hard. You can view how to SELECT VALUE from drop down list's popup in appium test. We can use findElements() method of selenium webdriver to locate and get all values from drop down list.

Aim Of Test And App To Use
Our main aim is to store all values from drop down list of android software application. We will use API Demos app in this android software automation test.

Manually you can view above screen from API Demos app's Home -> Views -> Controls -> 2. Dark Theme. -> Tap on Drop Down.

Create And Run Test
Created very simple software automation test to get all values from drop down of android application.
package Android;

import io.appium.java_client.MobileElement;

import java.util.List;
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 GetDropDownList {
 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 select() 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.
  //To hide keyboard 
  //Click on dropdown to open list.
  //Locate all drop down list elements 
  List dropList = driver.findElements("android:id/text1"));
  //Extract text from each element of drop down list one by one.  
  for(int i=0; i< dropList.size(); i++){
   MobileElement listItem = (MobileElement) dropList.get(i);   

 public void End() {

Run above android software automation test using appium to see how to get all values from drop down list. It will print all values in console.

1 comment:

  1. Hi, when I run this script on emulator, the list only contains part of the whole,
    it looks like the script just list those on the screen. we have to figure out a way to list all.