I'm using AndroidClientView
to do automated test. I found when the phone came into a new page, ViewClient
should dump the whole view. I guess if there is a way to speed up the test process, such as the page is only a transferred page, I don't need to get the specific ids of all the widgets, I just want to click a coordinate to pass through quickly. So I try to use Monkeyrunner with AndroidViewClient
, But I tried lots of ways, there were alway errors showed up. like "syntax error" "import error" or other errors..
Asked
Active
Viewed 83 times
0
1 Answers
0
If you don't want to identify any elements of the new screen and you know exactly the coordinates of the point you are going to tap then there's no need to invoke dump()
.
As an example, this is a slightly modified culebra
-generated test. It uses Calculator to enter an operation and verify the result, but as we know that the buttons are not changing we can comment out all the dump
s and sleep
s, and the result is the same but the test executes much faster.
def testSomething(self):
if not self.preconditions():
self.fail('Preconditions failed')
_s = CulebraTests.sleep
_v = CulebraTests.verbose
self.vc.dump(window=-1)
self.vc.findViewWithContentDescriptionOrRaise(u'''clear''').longTouch()
#self.vc.sleep(_s)
#self.vc.dump(window=-1)
self.vc.findViewByIdOrRaise(u'com.google.android.calculator:id/digit_1').touch()
#self.vc.sleep(_s)
#self.vc.dump(window=-1)
self.vc.findViewWithContentDescriptionOrRaise(u'''plus''').touch()
#self.vc.sleep(_s)
#self.vc.dump(window=-1)
self.vc.findViewByIdOrRaise(u'com.google.android.calculator:id/digit_2').touch()
#self.vc.sleep(_s)
#self.vc.dump(window=-1)
self.vc.findViewWithContentDescriptionOrRaise(u'''multiply''').touch()
#self.vc.sleep(_s)
#self.vc.dump(window=-1)
self.vc.findViewByIdOrRaise(u'com.google.android.calculator:id/digit_3').touch()
#self.vc.sleep(_s)
#self.vc.dump(window=-1)
self.vc.findViewWithContentDescriptionOrRaise(u'''equals''').touch()
self.vc.sleep(_s)
self.vc.dump(window=-1)
self.assertEquals(u'7', self.vc.findViewById(u'com.google.android.calculator:id/result').getText())

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