Try this
/**
-
Created by sargisazaryan on 7/3/15.
*/
public class IOSKeyboard {
private static final String GET_KEYBOARD_SCRIPT = “UIATarget.localTarget().frontMostApp().keyboard()”;
private final IOSDriver driver;public IOSKeyboard(IOSDriver driver) {
this.driver = driver;
}public void pressKey(String key) {
this.executeScript(this.pressKeyScript(key));
}public void type(String text) {
this.executeScript(this.typeScript(text));
}private void executeScript(String script) {
IOSDriver jsExecutor = this.driver;
jsExecutor.executeScript(this.keyboardScript(script), new Object[0]);
}private String pressKeyScript(String key) {
return String.format(".keys().firstWithName("%s").tap();", new Object[]{key});
}private String typeScript(String text) {
return String.format(".typeString("%s");", new Object[]{text});
}private String keyboardScript(String script) {
return GET_KEYBOARD_SCRIPT + script;
}
}