This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
6 / 21
Sep 2017

I am a beginner in Appium automation. The application I am testing, have this scenario where I need to tap on Search button from the native keyboard. I have tried with pressKeyCode method but get this error The method pressKeyCode(int) is undefined for the type WebElement

I am using the following Appium 1.4.16.1 with Java client 5.0.0-BETA8 Selenium 3.4.0

I don’t know what I am doing wrong. I have tried with earlier java client for appium as well but nothing have worked so far. Also, if there is a work around other than the pressKeyCode to do this?

  • created

    Sep '17
  • last reply

    Jan '19
  • 20

    replies

  • 2.8k

    views

  • 8

    users

  • 4

    links

This is the excerpt from my test code
driver.findElement(By.name(“Search Job Guides”)).sendKeys(“guide”);
driver.pressKeyCode(66);

I am now updating appium. Lets see if that works.

@mbasit how about:

 ((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.KEYCODE_SEARCH); //int KEYCODE_SEARCH = 84;

I have tried both
Updated appium version to 1.6.5
Also tried with this piece of code, still getting the same error “The method pressKeyCode(int) is undefined for the type AndroidDriver”

Sorry I meant still getting the same undefined method error.

Sure

Btw, I have tried with both AndroidDriver and WebDriver. Got the same error for both.

Hey,

Yes the code is working now. Thanks a ton for that but I am still unable to tap on the Search key. I have tried to tap on other keys and it works perfectly fine but it does not tap on the search key.

@mbasit tried and it was worked below with mine app:

        ((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.ENTER);
19 days later

@Aleksei @mbasit

I’m having the same problem. The code below does not seem to do anything against genymotion with soft keyboard enabled.

androidDriver.pressKeyCode(AndroidKeyCode.KEYCODE_SEARCH);

It would be great if someone who has workaround would share their solution.

7 months later

I also faced same issue, so as a solution i used below code:

TouchAction touchAction=new TouchAction(driver);
touchAction.tap(xPosition, yPosition).perform();

tap at paritcular coordinates. Using Appium inspector you can find the coordinates.

6 months later
1 month later

I have the same issue enter or search keys do not work on appium (Appium latest version, using real device)
driver.pressKeyCode(AndroidKeyCode.KEYCODE_ENTER);
I also tried keycode=66 that does not work either .

Any ideas? Thanks