0

I am using Appium (java) to automate my android app.
I am struck in a scenario where I need to enter text and press search / enter key from Soft keyboard.
I tried many solutions , but none of them worked.
Has anyone tried this?
TRIED SO FAR:

WebElement input = driver.findElement(By.id("myId"));
        input.sendKeys(value); // the value we want to set to input
        input.sendKeys(Keys.ENTER);
         genericMethods.wait(1000);
AnswerDroid
  • 1,873
  • 2
  • 33
  • 52

5 Answers5

1

Use this:

public void tapEnterButtonOnKeyboard() {
        ((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.ENTER);
    }
Gaurav
  • 1,332
  • 11
  • 22
1

Try something like this

selenium.keyPress("css=input.tagit-input.ui-autocomplete-input", "13");

Or

selenium.keyPressNative("10"); // Enter

References:

Typing Enter/Return key in Selenium

Press Enter key in Selenium script

http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/Keys.html

Community
  • 1
  • 1
Yogesh Khatri
  • 319
  • 3
  • 7
1

I am using the 1.11.0 Appium version and I tried this and it worked. Try this:

driver.executeScript("mobile:performEditorAction", ImmutableMap.of("action", "Search"));

Note:

The "driver" is an AppiumDriver type.

0

You can probably find that enter soft key object and execute tap event on it..It'll be under uiakeyboard node..

0

This solution in JavaScript using wd worked for me:

return driver.waitForElementById(<elementId>).type(<text to type>).click().execute( "mobile: performEditorAction", { "action": "search" } );

This allowed me to find a text field, input some text, and submit a search command (same as clicking the search icon in the keyboard). Of course, you have to replace <elementId> and <text to type> with the proper values. See http://appium.io/docs/en/commands/mobile-command/ for details on "mobile: performEditorAction".

Jarod Legault
  • 155
  • 1
  • 9