如何使用shell命令清除专注的编辑文本。 我尝试了
adb shell input keyevent KEYCODE_CLEAR // Not worked
adb shell input keyevent KEYCODE_DEL // Delete only one char
adb shell input keyevent KEYCODE_FORWARD_DEL // Not worked
我只能仅删除一个字符,有什么办法可以删除/清除专注的编辑文本。
这对我有用:
function clear_input() {
adb shell input keyevent KEYCODE_MOVE_END
adb shell input keyevent --longpress $(printf 'KEYCODE_DEL %.0s' {1..250})
}
到达:
clear_input
这将选择全部,然后选择返回。
您可以使用这种方式:
adb shell input keyevent --longpress 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67
Keycode_del
的键代码
如果您使用uiautomator(https://github.com/xiaocong/uiautomator
),则可以通过:
the Phone Text Field上的光标cobus for
adb shell input keyevent KEYCODE_CLEAR
driver.execute_script('mobile: pressKey', { keycode: 29, metastate: 4096 }) # KEYCODE_A with META_CTRL_ON
输入新电话号码:
driver.execute_script('mobile: pressKey', { keycode: 67 }) # KEYCODE_DEL