handling force close dialog using monkeyrunner
Am trying to click on Force close button using MonkeyRunner script, actually am doing automation for Browser and in bet'n I got force close hence I would like to handle it within my script so that it continues with the next script.
I used device.touch() method, passed the coordinates to touch Force close but it doe开发者_JAVA百科sn't work, also tried device.press("DPAD_UP", "DOWN_AND_UP") followed by device.press("DPAD_CENTER", "DOWN_AND_UP") but no use
Use device.press("DPAD_UP",MonkeyDevice.DOWN_AND_UP)
instead of device.press("DPAD_UP", "DOWN_AND_UP")
It might work.
What program is force closing? If its the monkey program (which is the program that runs on your phone that is used to talk to monkeyrunner) then you will actually need to run device=MonkeyRunner.waitforconnection()
again.
Sha,
Here, you need to detect when the force close occurs. Then send the press event of monkeyrunner like
device.touch(x,y)
Because, pressing keys like DOWN_AND_UP may highlight the wrong button and press.
Another issue here is to know the x,y co-ordinates of force close button. Rough method would be to take the snapshot of the force close and get the x,y co-ordinates of the button and use them as x,y.
Above solution would limit it to a certain device. To find force close button in all kinds of devices you should probably use pattern matching libraries like sikuli and get the co-ordinates.
精彩评论