Can't able to locate an element using appium?

I was trying to select a particular element in my mobile app to enter mobile my app i have done all other works…but i can’t able to locate my Mobile number field to enter Mobile number. currently it was performing the click operation on to a country code spinner prefix to my mobile number field…

The input field in my app is given below

The UI automator view is given below

The codes i tried are

driver.findElement(By.xpath("//android.widget.EditText[@text='Mobile Number']")).sendKeys("8129497946");



any solutions?

try(assuming the classname android.widget.EditText you have written is correct):

driver.findElement(By.xpath(“//android.widget.EditText[contains(@text, ‘Mobile Number’)]”)).sendKeys(“8129497946”);

You can also combine more than one attributes to form the xpath:

driver.findElement(By.xpath(“//android.widget.EditText[contains(@resource-id,‘ext-element-65’) and @text=‘Mobile Number’]”)).sendKeys(“8129497946”);

not working … while clicking on that mobile number input field …still it was performing the click operation on to a country code spinner prefix to my mobile number field

If it has any relation between the index number of Spinner and EditText (Both are 1)

Can you share the node details portion (where you get info regarding classname, id;etc)of the uiautomator viewer keeping the focus on Mobile Number Text Box

The above path should work based on the node details. Try the below path once -

driver.findElement(By.xpath("//android.widget.EditText[contains(@resource-id,‘ext-element-65’) and @index=‘1’]")).sendKeys(“8129497946”);

Still the same issue… after clicking on Mobile number input field the Spinner which list country code is popingup… it think the click going to that spinner with index 1 is happening first

If it has any relation between the index number of Spinner and EditText used for mobile number(Both are 1)?

Can you also share the node details of spinner. Lets see if they are exactly similar

Can’t seem to find any issue with it. Have you tried clicking with just the id instead of xpath-

Check the correct syntax once for using id.


Not working

I tried these three ways




next try:

List<AndroidElement> elList = driver.findElements(MobileBy.className("android.widget.spinner"));
        System.out.println("found number of elements: " + elList.size())
        if (!elList.isEmpty()) { //we got some elements
            // try first one
            try {Thread.sleep(10000);} catch (Exception e) {}
            // check if we had effect
            // now other way


i was getting the following error…
_The method setValue(String) is undefined for the type AndroidElement_

your java client is old. you can try replace “AndroidElement” to “WebElement”

android.widget.spinner IS THIS CORRECT?
OR android.widget.EditText

On your screenshot it is widget element.