Can't find element on Android


Hi there,
I have a registration screen on an Android app and I’m trying to fill all the text fields starting with first.
When reaching the screen, it scrolls down and the first edit text is not visible, so that the test will fail.
the code is:


Did anyone have this issue in the past?



Is the id correct?
Sometimes you might have to first click on the editbox and then enter values into it.

You can try clicking on edit boxes before entering text.



Actually, that id is the key from strings.xml file. Am i using it wrong?


Could you check what id you see when you inspect Android app using Appium Inspector?
If you see the same under resource-id in Appium inspector window also?



i am using uiautomatorviewer, since I’m trying right now to write for android and the keys located in strings.xml are not displayed there.
However the resource ID is the same for all the fields, because the edit text fields are displayed dynamically on the screen(i have this from dev-team :))



Were you able to click on edit fields using above ids?



i’m using uiautomatorviewer too. and basically i think the id you got will include the package of the app.
Example: If your app package is com.example.myapp so the id should be com.example.myapp:id/register.firstName.placeholder not just id by itself.
But i think you can copy the id from uiautomatorviewer.

In some case the UI is hierarchy so you can not select that element, but i think your case is not.


I cannot use com.example.myapp:id/register.firstName.placeholder because the “register.firstName.placeholder” is the name of the key located in strings.xml file.


so what is the id you got when inspect screenshots by uiautomator?


the id seen in uiautomatorviewer is “com.myapp.package:id/registration_field”

but all the existing fields have this id, since they are generated programmatically


I am experiencing the same issue of not being able to send keys to a text field when other text fields are present on the page. On a page with just one text field it works fine. I tried the suggestion (from sujata_kalluri) to click on the field before sending keys to it but that did not work either. When I manually tapped on the field (on the device) to focus in it then the keys were sent to the field. Any ideas on what else I can try? Thanks.


List EditText = driver.findElementsByClassName(“android.widget.EditText”);

Try the above code


Thanks for your response siva8kolli. I gave it a try and got the same result. Appium logs indicate that it thinks it found the element and sent the keys successfully. But nothing has happened in the screen.

Does it work for you when you have multiple EditText fields in a page?

info: --> POST /wd/hub/session/bb3df4a1-ce42-4d76-bc86-a360c968a7e0/element/2/click {"id":"2"}

info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"2"}]

info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"2"}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: click

info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}

info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"bb3df4a1-ce42-4d76-bc86-a360c968a7e0"}

info: <-- POST /wd/hub/session/bb3df4a1-ce42-4d76-bc86-a360c968a7e0/element/2/click 200 3025.789 ms - 76 {"status":0,"value":true,"sessionId":"bb3df4a1-ce42-4d76-bc86-a360c968a7e0"}

info: --> POST /wd/hub/session/bb3df4a1-ce42-4d76-bc86-a360c968a7e0/element/2/value {"id":"2","value":["admin"]}

info: [debug] Pushing command to appium work queue: ["element:setText",{"elementId":"2","text":"admin","replace":false}]

info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"2","text":"admin","replace":false}}

info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: setText

info: [debug] [BOOTSTRAP] [debug] Attempting to clear using UiObject.clearText().

info: [debug] [BOOTSTRAP] [debug] Sending plain text to element: admin

info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}

info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"bb3df4a1-ce42-4d76-bc86-a360c968a7e0"}

info: <-- POST /wd/hub/session/bb3df4a1-ce42-4d76-bc86-a360c968a7e0/element/2/value 200 3946.252 ms - 76 {"status":0,"value":true,"sessionId":"bb3df4a1-ce42-4d76-bc86-a360c968a7e0"}

info: --> GET /wd/hub/status {}

info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.3.1","revision":"1160ce02bb89c354cb99317985123acf39f0e7d3"}},"sessionId":"bb3df4a1-ce42-4d76-bc86-a360c968a7e0"}

info: <-- GET /wd/hub/status 200 2.273 ms - 155 {"status":0,"value":{"build":{"version":"1.3.1","revision":"1160ce02bb89c354cb99317985123acf39f0e7d3"}},"sessionId":"bb3df4a1-ce42-4d76-bc86-a360c968a7e0"}

Just trying different things I tried to get the “id” attribute of the EditText element and got the following exception

org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 11 milliseconds
For documentation on this error, please visit:
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03'
System info: host: 'BkMacBookPro.local', ip: '', 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.4', java.version: '1.7.0_71'
Session ID: fc34885f-5537-47f5-88e5-e72b865ed777
Driver info:
Capabilities [{newCommandTimeout=60000, platformVersion=4.4.3, platform=LINUX, databaseEnabled=false, javascriptEnabled=true, platformName=Android, deviceName=Android Emulator, browserName=Android, launchTimeout=60000, webStorageEnabled=false, networkConnectionEnabled=true, desired={newCommandTimeout=60000, platformVersion=4.4.3, deviceName=Android Emulator, platformName=Android, launchTimeout=60000}, locationContextEnabled=false, warnings={}, takesScreenshot=true}]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
        at java.lang.reflect.Constructor.newInstance(
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(
        at org.openqa.selenium.remote.RemoteWebDriver.execute(
        at io.appium.java_client.AppiumDriver.execute(
        at org.openqa.selenium.remote.RemoteWebElement.execute(
        at org.openqa.selenium.remote.RemoteWebElement.getAttribute(


@bc try to get how many elements are there and then try changing index get(i)
List EditText = driver.findElementsByClassName(“android.widget.EditText”);
for(int i=0;i<=EditText.size()-1;i++){
System.out.println(“EditText Number=”+i);
EditText .get(i).sendKeys(“Hi”);


Btw siva8kolli, does this work for you when you have multiple EditText fields on a page? Are you doing this on a Mac or Windows? I can’t say yet that it might be a Mac issue but I have seen this working on Windows and having this issue on Mac.


@bc I’m using same code on Windows and Mac. Its working


Hello Sir,
Is it EditButton or EditText on Second Line of code…??

Please Reply Soon.



I did the same but having This Error:
java.lang.IndexOutOfBoundsException: Index: 1, Size: 0

But Actually there are 5 components in List it is showing 0.



List EditText = driver.findElementsByClassName(“android.widget.EditText”);EditText.get(i).sendKeys(“Hi”);

Sorry its mistake (replace EditButton with EditText)



Is it possible to find element using xpath in appium
Please suggest ASAP, it would be so helpful for me. :blush: