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


#1

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


#2

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


#3

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


#4

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”);


#5

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();
driver.getKeyboard().sendKeys(“Poonam”);

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:

driver.findElement(By.id(“textboxID”)).sendKeys(“Poonam”)

or

driver.findElement(By.id(“textboxID”)).click();
driver.getKeyboard().sendKeys(“Poonam”);


#6

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

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?


#7

Does your test crash?


#8

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


#10

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

Thanks
Saurabh


#11

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


#12

Use this syntax to send input

WebElement email = driver.findElement(By.id(“com.appdev.myapp:id/et_email”));
email.click();
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*****************/