0

I have multiple test cases, for which i have respective monkeyrunner scripts. The thing i fidn with monkeyrunner is that in my case it becomes device dependant, as i record coordintes for my sequence of events. I have major issues as when i work, I do not get the same device always to test, as a result i end up making scripts for each device which is a lot of re-work. I new to python, so I was wondering if there is a way where i can keep the coordinates in a separtate file and my script generic, where in i can create multiple coordinate files to run with the same python code. How to do that

print "Initiating Calling process"
device1.touch(688,1620,'DOWN_AND_UP')
MonkeyRunner.sleep(4)

#Dialer
print "Opening Dialer"
device1.touch(536,1694,'DOWN_AND_UP')
MonkeyRunner.sleep(2)
device1.touch(526,664,'DOWN_AND_UP')
MonkeyRunner.sleep(4)
device1.type(ph_nmber_1)


#Device 1 calling 
print "Calling from Device 1"
device1.touch(536,1562,'DOWN_AND_UP')
MonkeyRunner.sleep(4)
device1.touch(536,1562,'DOWN_AND_UP')
MonkeyRunner.sleep(8)

for example this above code is for a particular device coordinates are according to that device how can i remove the hard coding of coordinates?

1 Answers1

0

One of the many reasons AndroidViewClient/culebra exist is precisely to solve the problem you mentioned. Unit tests and scripts generated by these tools are device-independent to the biggest possible extent.

For example, if content description is available you'll have something like

vc.findViewWithContentDescriptionOrRaise(u'''Story Album''').touch()

if text is available instead, you'll have

self.vc.findViewWithTextOrRaise(u'Create a new contact').touch()

otherwise, ids will be used

self.vc.findViewByIdOrRaise("com.samsung.android.app.episodes:id/timeline_add_album_layout").touch()

This video illustrates the feature running the same test on a phone and a tablet: http://dtmilano.blogspot.ca/2014/11/culebra-cross-device-application-tests.html

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134