Thursday, 29 January 2015

Python script to print touch coordinates using getevent command

We have prepared a batch file containing two major commands described as below :

      1. adb shell getevent -c 200 > getevent.txt
       Description:
       The above command will create 200 events including the touch event given by user
       manually. The touch event given by user will be differentiated via 'event3'

How does getevent works ? 
adb shell getevent ( connect device and use this command )
Which returns something like:
C:\>adb shell getevent
add device 1: /dev/input/event0
name: “qwerty2″
could not get driver version for /dev/input/mouse0, Not a typewriter
could not get driver version for /dev/input/mice, Not a typewriter
/dev/input/event0: 0001 0001 00000000
/dev/input/event0: 0003 0000 00000073
/dev/input/event0: 0003 0001 000000a8
/dev/input/event0: 0003 0001 00000014
/dev/input/event0: 0003 0001 00000014
/dev/input/event0: 0003 0001 00000000
/dev/input/event0: 0003 0001 00000000
/dev/input/event0: 0003 0001 00000000
/dev/input/event0: 0001 014a 00000001
        Which returns everything in hexidecimal, but you can’t send these commands directly back, you         had to convert them to decimal,
The actual X axis coordinates : 00000073 
The actual Y axis coordinates : 000000a8
These coordinates needs to be changed to decimal using python and monkeyrunner

2. monkeyrunner.bat testcall3.py
Description :
This command will execute following functions :
a. Open the getevent text file
b. Search for the touch events ( eg., search for 'event3')
c. Display the Hex format coming infront of event3 lines
d. Convert hex to int and then to decimal
e. Finally display the X and Y coordinates

Continue sharing interesting scripts !!
Thanks !!!

Friday, 23 January 2015

Monkey Scripts runtime error detection via ADB Logcat

This is my first script in front of you all regarding runtime error detection in Monkey Runner scripts. Hope you will enjoy it !!

Script Description :

1. Started any activity ( eg., open dialer)
2. Recording logs at the same time
3. finding a word in logs via find() function
4. If script shows error ( throws exception or opens any other activity apart from dialer) then capturing screenshot
5. Saving logs and moving to the other test case with the use of break function in python

Script :

 

 

 

 

 

 

 

 

 

Will share some more interesting scripts soon !