sendKeys is not working on uiautomator2 on android 7.0 with appium v1.7.2


sendKeys is not working on appium 1.7.2 for android 7.0. But same is working on android 6.0.1.


Can you give some more information?
-How does your code look like?
-To what are you sending the keys?


I have to set a username. I have a textbox where actually I am trying to sendKeys and set a username


Code Looks like this:
capabilities.setCapability(CapabilityType.BROWSER_NAME, “”);
capabilities.setCapability(“deviceName”, “");
capabilities.setCapability(“UDID”, "
capabilities.setCapability(“platformVersion”, “7.0”);
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“automationName”, “uiautomator2”);

I am sending text as
driver.findElement(By.xpath("//android.widget.EditText[@text=‘Enter username’]")).sendKeys(“Test”);


What seems to be the problem? Is your element found? Do you get any error, or just text isnt sent into your textBox?

Have you tried the following?

driver.findElement(By.xpath("//android.widget.EditText[@text=‘Enter username’]")).click();

Also the way you are locating your element isn’t the best practice. Try adding ID to your element (e.g. “textboxID”) and do the following:





I have tried
driver.findElement(By.xpath("//android.widget.EditText[@text=‘Enter username’]")).click();

But still its not working and for locating element using id, textbox so not have ‘resource-id’ field. So, I am using xpath for locating it.

I am using uiautomator2. Is it causing a problem?


Does your test crash?


No. Test passes but it does not enter any text value in textbox


Is the problem only with SendKeys or any other Action as well like clicking/tapping etc. This will help me to narrow down the scenario and i could suggest some option to overcome, please confirm



Just with sendKeys. Other actions such as click and tap are working


Use this syntax to send input

WebElement email = driver.findElement(“com.appdev.myapp:id/et_email”));;
email.sendKeys("[email protected]");

But make sure you have hidden the keyboard while input using following line of code put it before your sendKey code

/******HIDING KEYBOARD DURING INPUT*****************/
	capabilities.setCapability("unicodeKeyboard", false);
	capabilities.setCapability("resetKeyboard", false);
	/******HIDING KEYBOARD DURING INPUT*****************/