I am using monkey runner.
I have on Screen 1 and I need to fill the form of the page and submit.
I need to take the focus to the first field and need to enter the text.
How to give the focus to any text field or can i type any way?
Please let me know..
REgards, Chandra
Yes, one can focus on a text field and type text in that field.
I did it using Python. Followings are relevant lines from my code:
import os, subprocess
import sys
import time
import random
import string
import re
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
#connect to the device
device = MonkeyRunner.waitForConnection(99, "emulator-5554")
Then, launch the relevant activity and move to the text field using the press function.
device.press ('KEYCODE_DPAD_DOWN', MonkeyDevice.DOWN_AND_UP)# move down
Normally, when you reach a text field then focus is already there, but if it is not then click the field.
device.press ('KEYCODE_DPAD_CENTER', MonkeyDevice.DOWN_AND_UP)#click the field
Now, one can type the text using the type function.
device.type('text')