i'm trying automate the search scenario, i mean pass one text to input field and hit enter button of keyboard.
so far, i tried below:
((AndroidDriver)driver).pressKeyCode(AndroidKeyCode.ENTER);
driver.getKeyboard().sendKeys(Keys.ENTER);
driver.press_keycode(66)
Robot robot;
try {
robot = new Robot();
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
} catch (AWTException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
and, i'm using java-client 6.0.0-BETA2
can anyone help in this?
Try following code. It must work:
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
((AndroidDriver<MobileElement>) driver).pressKey(new KeyEvent(AndroidKey.ENTER));
Before using enter key, you must first click on text input field.