2013-09-24 3 views
-1

아래 코드에서 내 xml 레이아웃 파일에서 언급 한 것처럼 버튼의 ID 또는 뷰를 어떻게 사용할 수 있습니까? dump.py -i를 실행하면 고유 한 ID가 표시되지만 xml 파일에서 언급 한 것처럼 표시되지는 않습니다.AndroidViewClient/culebra는 어떻게 실행합니까?

touchProject = vc.findViewByIdOrRaise('id/btnHome') 
touchProject.touch() 

Culebra를 사용해야하는 경우 환경 설정 및 실행 방법을 자세히 알려주십시오. 환경 변수에 Android View Client Home을 설정했습니다.

내 현재 스크립트보기

#! /usr/bin/env monkeyrunner 
''' 
Copyright (C) 2012 Diego Torres Milano 
Created on Feb 3, 2012 

@author: diego 
''' 


import re 
import sys 
import os 
import java 
# this must be imported before MonkeyRunner and MonkeyDevice, 
# otherwise the import fails 
#try: 
#ANDROID_VIEW_CLIENT_HOME = os.environ['ANDROID_VIEW_CLIENT_HOME'] 
#except KeyError: 
#print >>sys.stderr, "%s: ERROR: ANDROID_VIEW_CLIENT_HOME not set in environment" % __file__ 
#sys.exit(1) 
#sys.path.append(ANDROID_VIEW_CLIENT_HOME + '/src') 
try: 
    sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src')) 
except: 
    pass 
from com.dtmilano.android.viewclient import ViewClient 
# Imports the monkeyrunner modules used by this program 
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice 
#starting script 
print "start" 
# Connects to the current device, returning a MonkeyDevice object 
device, serialno = ViewClient.connectToDeviceOrExit() 
#device connected 
print "connection started" 

# sets a variable with the package's internal name 
package = 'org.droidtv.TvPlayerFunctionalTestApp' 
# sets a variable with the name of an Activity in the package 
activity = '.VideoViewActivity' 
# sets the name of the component to start 
runComponent = package + '/' + activity 
# Runs the component 
device.startActivity(component=runComponent) 
#device set to sleep for 4 seconds 
print "wait for 4 seconds" 
# first screen shot event 
MonkeyRunner.sleep(2); 
vc = ViewClient(device, serialno) 
vc.dump() 
#root = vc.getRoot() 
#touchProject = vc.findViewWithTextOrRaise('', root) 
touchProject = vc.findViewByIdOrRaise('id/btnHome') 
touchProject.touch() 
# wait for screenshot to save 
MonkeyRunner.sleep(2); 
# Takes a screenshot 
result1 = device.takeSnapshot() 
result1.writeToFile('E:\NewApp\shot1.png','png') 
# wait for 3 seconds 
MonkeyRunner.sleep(2); 
# Pressing Watch Tv Button 
print "wait for NextButton to be pressed" 
vc.dump() 
touchProject = vc.findViewByIdOrRaise('id/no_id/6') 
touchProject.touch() 
MonkeyRunner.sleep(2); 
result1 = device.takeSnapshot() 
result1.writeToFile('E:\NewApp\WatchTv.png','png') 
print "Wait for Home Button to be pressed" 
vc.dump() 
touchProject = vc.findViewByIdOrRaise('id/no_id/11') 
touchProject.touch() 
result1 = device.takeSnapshot() 
result1.writeToFile('E:\NewApp\Home.png','png') 
MonkeyRunner.sleep(2); 
print "Pressing Channel Setting Button" 
vc.dump() 
touchProject = vc.findViewByIdOrRaise('id/no_id/11') 
touchProject.touch 
result1 = device.takeSnapshot() 
result1.writeToFile('E:\NewApp\ChannelSetting.png','png') 
MonkeyRunner.sleep(2) 
+0

이것은 내가 물어 본 바보 같은 질문입니다. – SajidKhan

답변

1

다운로드 AndroidViewClient 나를 위해 일을했다 아래처럼 감사드립니다.

관련 문제