Not able to send text to Content-desc field using Appium with sendkeys() method

am trying to automate Google Hangouts app using appium(in java).

I am using Appium CLient v 1.3.7 I am using Samsung Galaxy S5 Android os version 5.0.

I want to send text using element.sendkeys() method to the field having content description as “Type a name,email,number or circle” field. Appium does find the field but after executing sendkeys() command, it does not show anything in the same field. Appium clicks at the left edge of the app.

This field does not have resource-id. I tried element.click() before using sendkeys() but din’t help. Any suggestion?

dr = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”),capa);
WebElement el1 = dr.findElementByName(“Type a name, email, number or circle”);
el1.click();
el1.sendKeys(“0000000”);

Try using driver.findElementByAccessibilityId("Type a name, email, number or circle");

No it’s not working too. It seems Appium does find the element but when it accesses that element , what i can observe from the screen is, it just touches the left edge of the element.

Try like this : driver.findelement(By.name …) or you can find elements by Class Name and then get the content-desc property and identify the element you require.

Thanks Umar. I tried this in following way …however no success. everytime Appium touches somewhere else …like on the left edge of the field

  1. WebElement el1 = dr.findElement(By.name(“Type a name, email, number or circle”));

  2. WebElement el1 = dr.findElementByXPath("//android.widget.EditText[@text=‘Type a name, email, number or circle’]");

  3. By your way
    dr = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”),capa);

     			List<WebElement> text_view = dr.findElements(By.className("android.widget.EditText"));
     			Iterator it_12 = text_view.iterator();
     			while(it_12.hasNext())
     			{
     				WebElement el1  = (WebElement)it_12.next();
     				
     				
     				String Str1= el1.getAttribute("name");
     				
     				if(Str1.contentEquals("Type a name, email, number or circle"))
     				{
     					
     					el1.sendKeys("00000000");
     				}
     			}
     		}

I’m not sure if they have this in Java but with Python, i used the send_text() API and it works fine. There must be something similar in Java.

Good luck,

Jonathan

It sounds like your problem is with sendKeys, not finding the element. There have been some issues recorded with sendKeys recently. One such issue is recorded here: https://github.com/appium/java-client/issues/89 along with a solution.

Please use 1.3.7.2 Appium with appium java client 2.2 library and see if that works.

Are you using windows / Mac?

Also please send the appium logs.

I think it is not related to sendKeys since I am using sendKeys and it is working fine for me

I think appium is unable to find the element. Use xpath like this:

el = driver.findElementByXPath("//android.widget.ListView/descendant::android.widget.RelativeLayout[use some property]/descendant::android.widget.RelativeLayout/descendant::android.widget.TextView[@index=‘1’]");

I have highlighted the root nodes in attachment from where you can traverse in the hierarchy and reach to the text field

Hope that would help.

I am using Windows. will attach logs on tuesday
Thanks a lot for your help.

HI Umar,

I can’t find the field using xpath mentioned by you.
However i tried with findElementByAccessibilityId and logs are attched.
i am using windows machinelogs.txt (12.3 KB)

I checked the logs and it seems element is found but the sendkeys is not doing it’s intended function.

info: [debug] [BOOTSTRAP] [debug] Sending plain text to element: 123456
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}

Re: xpath : I just gave the example. You were suppose to build the xpath on your own.