Can't find an element on the screen by using Android Find By


There are several EditText in my screen and I want to specify them by uiAutomator , these are several ways I tried:
#approach 1
@AndroidFindBy(uiAutomator = “new UiSelector().className(“android.widget.TextView”).index(1)”)
@iOSFindBy(xpath = “//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAButton[3]”)
public WebElement garden;

#approach 2
androidDriver.findElementByAndroidUIAutomator(“new UiSelector().className(“android.widget.EditText”).index(0)”).sendKeys(“2”);

These 2 way cause a NoSuchElementException.

but this way works:

I use java_client 3.0.0 and Appium server

Any suggestions and discussion are welcomed, thanks!

paste the main log here:

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: 1.36 seconds
For documentation on this error, please visit:
Build info: version: ‘2.46.0’, revision: ‘61506a4624b13675f24581e453592342b7485d71’, time: ‘2015-06-04 10:22:50’
System info: host: ‘58-PC’, ip: ‘’, ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.7.0_79’
*** Element info: {Using=-android uiautomator, value=new UiSelector().className(“android.widget.EditText”).index(2)}
Session ID: 5d88ccd2-733b-4d4c-bbd5-255a87467551
Driver info:
Capabilities [{platform=LINUX, javascriptEnabled=true, browserName=Android, networkConnectionEnabled=true, desired={deviceName=252e4425, platformName=Android, unicodeKeyboard=true, resetKeyboard=true}, locationContextEnabled=false, platformVersion=5.0, databaseEnabled=false, deviceName=252e4425, platformName=Android, webStorageEnabled=false, unicodeKeyboard=true, resetKeyboard=true, warnings={}, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
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.DefaultGenericMobileDriver.execute(
at io.appium.java_client.AppiumDriver.execute(
at org.openqa.selenium.remote.RemoteWebDriver.findElement(

Simple way would be

List<…AndroidElements> L1 = driver.findElements(By.classname(“xyz”)):
For(AndroidElements e1:l1)

Put condition based on index


I know this way is simple and worked ,but I want to use one script for two platform(android and ios) so I prefer to use @AndroidFindBy and @iOSFindBy to achieve that.

I have got the TextViews on the screen by findElementsByAndroidUIAutomator, after that I use findElementByAndroidUIAutomator(“new UiSelector().className(”**").index(4)") to get the fifth item(I have confirmed that the fifth item exist) it still throw a NoSuchElementException.

till now ,seems we can locate the issue to be use index to locate an element?

Can anyone try this way and test if this is a common issue?

I can use other ways to go through this issue in my work ,but every issue fix will make appium better, let’s do that together.