Spinner(Drop down) selection in Android Mobile APP

login screen.

  1. In Login screen (Country, User name, Password) available.
  2. Country is Spinner(drop down list) & data is in alphabetical order.
  3. I need to select ex “United Kindom”.
    How to select that country.

Spinner opening time showing 6 countries(America, Australia, etc. I can select those countries.


So America is selecting No problem is this case.

Now i Need to select “United Kingdom”

driver.findElement(By.name(“United Kingdom”);

not working
I need to scroll right?
How to scroll, can you tell me please…

hi guys.

please help me


You can use javascript to scroll window.
JavascriptExecutor js = (JavascriptExecutor)driver;

0,3000 - x,y co-ordinates are based on screen size


after click on spinner ,you can use
driver.scrollToExact(“United Kingdom”)

sujata_kalluri & Aravind for your respnce…

Thank’Q Arvind its working…

One more think
I need to select United Kingdom in the spinner.
I used driver.scrollToExact(“United Kingdom”);
I need to Pic the exact word ‘United Kingdom’
In my list 300 Country’s are available
it is scrolling slowly like user swapping.
How to pic exact word???

Use getText command immediate after driver.scrollToExact(“United Kingdom”);
driver.scrollToExact(“United Kingdom”);

i am using same for click(After scroll ), so i think for getText also it should word.

HI Arvind,


driver.scrollToExact(“United Kingdom”);

can you tell me in (locator) place what i will give.

driver.scrollToExact(“United Kingdom”);
driver.findElementByName(“United Kingdom”).getText();

Locator could be Name,Id,Xpath,Content

Hi Arvind,

I am not able to select the state by using below code
driver.scrollToExact(“Uttar Pradesh”);
driver.findElementByName(“Uttar Pradesh”).getText();

Code is trying to pick the Uttar Pradesh state but numeric keyboard was already opened for mobile number field.

Can you please help me, how to hide the keyboard? so that i could call below script
river.scrollToExact(“Uttar Pradesh”);
driver.findElementByName(“Uttar Pradesh”).getText();

You can provide the index of the element and then use sendKeys method for the text to select.


It scrolls but doesnt click. what did you do? I am using the exact code what you mentioned here

scroll to text is not working, do you guys another way to simular scroll to text



is the above is working for Drop down, as to select any drop down we need Select class ? Can you lease update me ?

By.name has been deprecated.
Try using findElementByAndroidUIAutomator
driver.findElementByAndroidUIAutomator(“new UiSelector().text(“America”)”).click();

try this

public void swipeUpUntilTextExists(String expectedText, int howManyTimesToSwipe) {
	int i = 0;
	do {
		if (i == howManyTimesToSwipe)
	} while (!driver.getPageSource().contains(expectedText));

swipe method:
public void swipeUP(){
Dimension size = driver.manage().window().getSize();
// calculate coordinates for vertical swipe
int startVerticalY = (int) (size.height * 0.8);
int endVerticalY = (int) (size.height * 0.2);
int startVerticalX = (int) (size.width / 2);
new TouchAction(driver).press(point(startVerticalX, startVerticalY)).waitAction(waitOptions(ofSeconds(3))).moveTo(point(startVerticalX, endVerticalY)).release().perform();

or this with uiAutomator:
@AndroidFindBy(uiAutomator = “new UiScrollable(new UiSelector()).scrollIntoView(text(“Tokyo”))”)
public MobileElement tokyo;


I used driver.scrollToExact(“United Kingdom”).click();
but it is keep on scrolling and not selecting the country