如何使用 Appium 在 Android Numpad 中输入数值? [英] How to enter numeric values to Android Numpad using Appium?
问题描述
我试过使用:
- send_keys 方法:
driver.send_keys("12345678");
这不会出现任何错误,但甚至没有输入任何文本.
This does not give any error , yet doesn't even enter any text.
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);
这给出了一个错误,说org.openqa.selenium.WebDriverException:尚未实现"
This gives an error saying 'org.openqa.selenium.WebDriverException: Not yet implemented'
我使用的是 appium java 客户端 2.2.0
I'm using appium java client 2.2.0
推荐答案
以下是android数字小键盘上数值的方法
Below are the ways to numeric values from android numeric keypad
1) driver.sendkeyEvent(int key);
关键代码列表:a - z-> 29 - 54
List Of Key codes: a - z-> 29 - 54
"0" - "9"-> 7 - 16
"0" - "9"-> 7 - 16
返回按钮 - 4,菜单按钮 - 82
BACK BUTTON - 4, MENU BUTTON - 82
上 19、下 20、左 21、右 22
UP-19, DOWN-20, LEFT-21, RIGHT-22
选择(中间)按钮 - 23
SELECT (MIDDLE) BUTTON - 23
空格 - 62,SHIFT - 59,回车 - 66,退格 - 67
SPACE - 62, SHIFT - 59, ENTER - 66, BACKSPACE - 67
您可以在此处获得键码的说明:https://code.google.com/p/androhid/wiki/Keycodes
You can get the explaination of keycodes here: https://code.google.com/p/androhid/wiki/Keycodes
2) driver.findElementByID("LocatorID").sendKeys("123");
请在评论中留下问题
这篇关于如何使用 Appium 在 Android Numpad 中输入数值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!