1

I am looking forward to scroll a list with the help of Android view client(dtmilano) .The list has 109 elements and only 10 are visible. So i need to scroll down and again perform vc.dump . Kindly guide with a sample python code to perform scroll down operation. Thanks

Ken Y-N
  • 14,644
  • 21
  • 71
  • 114
Arush
  • 13
  • 5

1 Answers1

1

You should use MonkeyDevice.drag() and your script would look something like this

list = vc.findViewByIdOrRaise(someid)
(x, y, w, h) = list.getPositionAndSize()
start = (int(x+w/2.0), y+h)
end = (int(x+w/2.0), y)
# scroll 5 times
for i in range(5):
    vc.device.drag(start, end, 1.0, 10)
Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
  • Hi Diego , Thank you for the guidance.However i am not able to drag the window vertically with the above code. I am using Emulator with GoogleAPI 10,resolution is w=768 and h=1280. The list which i want to scroll has the below dimensions , x=0,y=250,w=768,h=1030. Further , i am able to drag the list vertically with device.drag((380,1000),(380,10),0.10,10). I wish to set these values at run time based on the list dimensions. Thank you. – Arush Jul 10 '13 at 11:47
  • Also what was happening earlier,the drag method was clicking the element instead of dragging.I tried to extend device class to override_onLongClick_method,here is the sample code: class TestDevice(MonkeyRunner): def __new__(self): return MonkeyRunner.waitForConnection(30,deviceId='emulator-5554') def __init__(self): MonkeyDevice.__init__(self) def takeSnapshot(self): a=5 return a However without implementing this , the drag method started working as desired .Is it an issue or there was something wrong with emulator as i again created an emulator and that worked. – Arush Jul 10 '13 at 11:58
  • Hi Diego,Yes it worked with slight modification.Here is the modified parameters, start = (int(x+w/2.0), y+h-250) end = (int(x+w/2.0), y-250) Thank you Sir for the guidance. – Arush Jul 15 '13 at 06:23