1

my problem is after:

device.drag((200,350),(200,150))
MonkeyRunner.sleep(6)
vc.dump()

My test stops working. Does anyone know of a command I can use instead of vc.dump()? I need a command after device.drag((200,350),(200,150)) that will allow my test to continue working.

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

1 Answers1

0

Using culebra to generate a script while on Launcher on a 4.2 emulator (API 17) and adding drag at the end the script works as expected.

#! /usr/local/bin/shebang monkeyrunner -plugin $AVC_HOME/bin/androidviewclient-$AVC_VERSION.jar @!
# -*- coding: utf-8 -*-
'''
Copyright (C) 2013  Diego Torres Milano
Created on 2013-05-13 by Culebra v0.9.8

                      __    __    __    __
                     /  \  /  \  /  \  /  \ 
____________________/  __\/  __\/  __\/  __\_____________________________
___________________/  /__/  /__/  /__/  /________________________________
                   | / \   / \   / \   / \   \___
                   |/   \_/   \_/   \_/   \    o \ 
                                           \_____/--<
@author: Diego Torres Milano
@author: Jennifer E. Swofford (ascii art snake)
'''


import re
import sys
import os


from com.dtmilano.android.viewclient import ViewClient

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

device, serialno = ViewClient.connectToDeviceOrExit()
vc = ViewClient(device, serialno, autodump=False)
vc.dump(window='-1')

print "### before drag ###"
vc.traverse(transform=ViewClient.TRAVERSE_CIT)
device.drag((450,200),(50,200))
MonkeyRunner.sleep(6)

print "### after drag ###"
vc.dump()
vc.traverse(transform=ViewClient.TRAVERSE_CIT)
Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
  • Thank you, but what should I do if my emulator with API<16 – user2378438 May 14 '13 at 07:33
  • Can you try vc.touch or vc.type instead of vc.traverse(transform=ViewClient.TRAVERSE_CIT) ? – user2378438 May 14 '13 at 07:44
  • Should work on emulator with API < 16 too. Try it and tell us the results. Select a View from the traverse dump, and add a touch(), provide the results here too. – Diego Torres Milano May 14 '13 at 16:43
  • This is a part of my test: – user2378438 May 16 '13 at 14:55
  • device.drag((200,350),(200,150)) vc.dump() vc.traverse(transform=ViewClient.TRAVERSE_CIT) email = vc.findViewById("id/registrEMailEditText")email.type('test'+random.choice('abcdefghijopklmnvzx')+random.choice('abcdefghijopklmnvzx')+random.choice('abcdefghijopklmnvzx')+'@test'+random.choice('abcdefghijopklmnvzx')+random.choice('abcdefghijopklmnvzx')+'.com') MonkeyRunner.sleep(6) – user2378438 May 16 '13 at 14:56
  • Use findViewByIdOrRaise() to verify that views were found – Diego Torres Milano May 16 '13 at 14:58
  • After command vc.traverse(transform=ViewClient.TRAVERSE_CIT), It click some other Button, but it should send text to edit text. It seems: after device.drag((200,350),(200,150)) androidviewclient use the same coordinate as before device.drag((200,350),(200,150)). – user2378438 May 16 '13 at 15:01
  • With command findViewByIdOrRaise(). I have got an error: ]Traceback (most recent call last): File "c:\android-sdk\tools\test1.py", line 61, in email = findViewByIdOrRaise("id/registrEMailEditText") NameError: name 'findViewByIdOrRaise' is not defined – user2378438 May 16 '13 at 15:06
  • `email = vc.findViewByIdOrRaise("id/registrEMailEditText")` – Diego Torres Milano May 16 '13 at 19:41
  • Yes, after command email = vc.findViewByIdOrRaise("id/registrEMailEditText"), I have got an error:]Traceback (most recent call last): File "c:\android-sdk\tools\test1.py", line 61, in email = findViewByIdOrRaise("id/registrEMailEditText") NameError: name 'findViewByIdOrRaise' is not defined – user2378438 May 17 '13 at 16:37
  • The error message is showing something different: ` line 61, in email = findViewByIdOrRaise("id/registrEMailEditText")` (**No vc. in that line**) – Diego Torres Milano May 17 '13 at 17:52