AnswerDroid February 2016

How to Handle soft keys like search , enter etc in Appium android

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

Answers


Gaurav February 2016

Use this:

public void tapEnterButtonOnKeyboard() {
        ((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.ENTER);
    }


sunder kandasamy February 2016

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


Yogesh Khatri February 2016

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

Post Status

Asked in February 2016
Viewed 2,037 times
Voted 12
Answered 3 times

Search




Leave an answer