我知道MonkeyRunner有点被弃用,但我仍有一个奇怪的问题。
如果我通过Monkeyrunner的触摸事件打开设置用户选项不存在,
如果我这样做同样的话。
FLAG_ACTIVITY_NEW_TASK = 0x10000000
package = 'com.android.settings'
activity='.Settings'
runComponent = package + '/' + activity
device.startActivity(component=runComponent, flags=FLAG_ACTIVITY_NEW_TASK)
有谁知道为什么,或者如何让用户使用MonkeyRunner显示或打开?
运行Android v6.0.1。
谢谢,
尤金
答案 0 :(得分:0)
您可以使用AndroidViewClient/culebra来执行此操作。
这是一个culebra
脚本略微修改,以便在滚动时检查用户,但大部分是使用Culebra GUI生成的:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''
Copyright (C) 2013-2014 Diego Torres Milano
Created on 2016-01-11 by Culebra v11.0.8
__ __ __ __
/ \ / \ / \ / \
____________________/ __\/ __\/ __\/ __\_____________________________
___________________/ /__/ /__/ /__/ /________________________________
| / \ / \ / \ / \ \___
|/ \_/ \_/ \_/ \ o \
\_____/--<
@author: Diego Torres Milano
@author: Jennifer E. Swofford (ascii art snake)
'''
import re
import sys
import os
import unittest
from com.dtmilano.android.viewclient import ViewClient, CulebraTestCase
TAG = 'CULEBRA'
class CulebraTests(CulebraTestCase):
@classmethod
def setUpClass(cls):
cls.kwargs1 = {'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False}
cls.kwargs2 = {'forceviewserveruse': False, 'useuiautomatorhelper': False, 'ignoreuiautomatorkilled': True, 'autodump': False, 'startviewserver': True, 'compresseddump': True}
cls.options = {'start-activity': None, 'concertina': False, 'device-art': None, 'use-jar': False, 'multi-device': False, 'unit-test-class': True, 'save-screenshot': None, 'use-dictionary': False, 'glare': False, 'dictionary-keys-from': 'id', 'scale': 0.5, 'find-views-with-content-description': True, 'window': -1, 'orientation-locked': None, 'save-view-screenshots': None, 'find-views-by-id': True, 'log-actions': False, 'use-regexps': False, 'null-back-end': False, 'auto-regexps': None, 'do-not-verify-screen-dump': True, 'verbose-comments': False, 'gui': True, 'find-views-with-text': True, 'prepend-to-sys-path': False, 'install-apk': None, 'drop-shadow': False, 'output': None, 'unit-test-method': None, 'interactive': False}
cls.sleep = 5
def setUp(self):
super(CulebraTests, self).setUp()
def tearDown(self):
super(CulebraTests, self).tearDown()
def preconditions(self):
if not super(CulebraTests, self).preconditions():
return False
return True
def testSomething(self):
if not self.preconditions():
self.fail('Preconditions failed')
_s = CulebraTests.sleep
_v = CulebraTests.verbose
self.vc.dump(window=-1)
self.vc.uiDevice.openQuickSettings()
self.vc.sleep(_s)
self.vc.dump(window=-1)
self.vc.findViewWithContentDescriptionOrRaise(u'''Settings''').touch()
self.vc.sleep(_s)
self.vc.dump(window=-1)
users = None
com_android_settings___id_dashboard = self.vc.findViewByIdOrRaise("com.android.settings:id/dashboard")
com_android_settings___id_dashboard.uiScrollable.flingToBeginning()
attempts = 10
while attempts > 0:
users = self.vc.findViewWithText(u'Users')
if users:
break
com_android_settings___id_dashboard.uiScrollable.flingForward()
self.vc.dump(window=-1)
self.vc.sleep(_s)
com_android_settings___id_dashboard = self.vc.findViewByIdOrRaise("com.android.settings:id/dashboard")
attempts -= 1
if not users:
self.fail("Users not found")
if __name__ == '__main__':
CulebraTests.main()