In Android testing sending keys to text field does not work when multiple text fields are present in the page

When testing with Android I am not able to enter text in a field “if there are other text fields present in the page”. If a text field is on a page by itself then it works. I am able to find the element using xpath (e.g.) //android.webkit.WebView/android.view.View/android.widget.EditText[1]. Subsequent send keys to this element does not do anything. I see the same behavior using the device and appium’s inspector. When testing on the device if I manually tap on the field to activate then I am able to send keys to it. So I tried to click/tap programmatically on it before sending keys and that did not work. Any ideas what else I could try?

Note that this works correctly in iOS testing.

Thanks.

Facing same issue for Android through on mac

Nishal_Sinha, have you tried this on Windows? Does it work?

No it doesn’t works at all…

I am using a workaround for my situation and it works. I noticed (using Appium Inspector) that the EditText elements that I was trying to interact with had negative coordinates in the location attribute. So before interacting with them I send the ‘rotate’ command as shown below which forces a redraw of the page. After this the location coordinates show correctly (which tells me that it’s in a sane state) and I am able to send text to these elements. Hope this helps.

((AppiumDriver) driver).rotate(ScreenOrientation.LANDSCAPE);
((AppiumDriver) driver).rotate(ScreenOrientation.PORTRAIT);

But is it works for Android on Mac???

Have you opened this issue on GitHub ?? I dont have an idea why Appium guys are not resolving this Issue?

Thanks,
Nischal

Does the orientation work on a real device?

My tests were on a real device and the rotate commands I mentioned above worked.