This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
1 / 11
May 2018

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

  • created

    May '18
  • last reply

    May '18
  • 10

    replies

  • 821

    views

  • 4

    users

  • 2

    links

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

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?

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

Thanks
Saurabh

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

Use this syntax to send input

WebElement email = driver.findElement(By.id(“com.appdev.myapp:id/et_email”));
email.click();
email.sendKeys("mubbashir@email.com");

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*****************/