how to delete text from a text field using monkeyrunner API (Python script)

廉价感情. 提交于 2019-12-10 10:12:51

问题


I am trying to delete text from a text field using monkeyrunner API . I am writing script in python.

There are key events like " KEYCODE_FORWARD_DEL","KEYCODE_DEL" and to move the cursor to the end "KEYCODE_MOVE_END".

I am trying to delete text, for this, I tried to move the cursor to the end but"KEYCODE_MOVE_END" did not work. Cursor did not move at all.

Then, I tried to use " KEYCODE_FORWARD_DEL" but it also did not work.

These, keys are working for the text field in which I entered text using my script, but these are not working for the fields, which were already filled.

Can any one, please guide me?


回答1:


This worked for me, though haven't tried setting a Exchange account:

  fieldLength = 50
  # select all the chars
  self.device.press('KEYCODE_SHIFT_LEFT', MonkeyDevice.DOWN)
  for i in range(fieldLength):
     self.device.press('KEYCODE_DPAD_LEFT', MonkeyDevice.DOWN_AND_UP)
     MonkeyRunner.sleep(1)
  self.device.press('KEYCODE_SHIFT_LEFT', MonkeyDevice.UP)

  # delete them
  self.device.press('KEYCODE_DEL', MonkeyDevice.DOWN_AND_UP)


来源:https://stackoverflow.com/questions/12493101/how-to-delete-text-from-a-text-field-using-monkeyrunner-api-python-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!