[英]How to enter numeric values to Android Numpad using Appium?
I have tried using : 我尝试过使用:
driver.send_keys("12345678");
This does not give any error , yet doesn't even enter any text. 这不会给出任何错误,但甚至不输入任何文本。
2.Sending key event 2.发送关键事件
HashMap numKeyObject = new HashMap();
numKeyObject.put("keycode", 145);
numKeyObject.put("keycode", 146);
numKeyObject.put("keycode", 147);
numKeyObject.put("keycode", 148);
numKeyObject.put("keycode", 149);
numKeyObject.put("keycode", 150);
((JavascriptExecutor ) driver).executeScript("mobile: keyevent", numKeyObject);
This gives an error saying 'org.openqa.selenium.WebDriverException: Not yet implemented' 这给出了一个错误'org.openqa.selenium.WebDriverException:尚未实现'
I'm using appium java client 2.2.0 我正在使用appium java client 2.2.0
Below are the ways to numeric values from android numeric keypad 以下是从android数字键盘输入数值的方法
1) driver.sendkeyEvent(int key); 1) driver.sendkeyEvent(int key);
List Of Key codes: a - z-> 29 - 54 密钥列表:a - z-> 29 - 54
"0" - "9"-> 7 - 16 “0” - “9” - > 7 - 16
BACK BUTTON - 4, MENU BUTTON - 82 BACK BUTTON - 4,MENU按钮 - 82
UP-19, DOWN-20, LEFT-21, RIGHT-22 UP-19,DOWN-20,LEFT-21,RIGHT-22
SELECT (MIDDLE) BUTTON - 23 SELECT(MIDDLE)按钮 - 23
SPACE - 62, SHIFT - 59, ENTER - 66, BACKSPACE - 67 空间 - 62,SHIFT - 59,ENTER - 66,BACKSPACE - 67
You can get the explaination of keycodes here: https://code.google.com/p/androhid/wiki/Keycodes 您可以在此处获取密钥代码的说明: https : //code.google.com/p/androhid/wiki/Keycodes
2) driver.findElementByID("LocatorID").sendKeys("123"); 2)driver.findElementByID(“LocatorID”)。sendKeys(“123”);
please leave question in comment 请在评论中留下问题
尝试这样做:
driver.findElementByID("locator").sendKeys("");
The best and easier way is :
element.setValue("");
for eg:
@AndroidFindBy(id = "com.android.life.login:id/et_pin")
private MobileElement unlockPhone;
public void unlockPhone() {
unlockPhone.setValue("1111");
System.out.println("Lockscreen Unlocled");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.