我正在尝试自动安装UC浏览器。我能够进入决赛"进入UC"按钮(在屏幕截图下方)按钮活动。我需要模拟"Enter UC"
按钮上的点击。
我尝试了多种方式(如下所列)来模拟点击但没有任何效果。
1.)使用UIautomator转储 - 我尝试获取转储并解析它以获取绑定但是当我使用adb shell uiautomator dump
获取转储时,我无法获得完整的完整UI层次结构(可能因为它只提供原生视图的UI - 我不确定如果你有任何指针请告诉我。
转储:
<?xml version="1.0" encoding="UTF-8" standalone="true"?>
-<hierarchy rotation="0">
-<node bounds="[0,38][480,800]" selected="false" password="false" long-clickable="false" scrollable="false" focused="false" focusable="false" enabled="true" clickable="false" checked="false" checkable="false" content-desc="" package="com.UCMobile.intl" class="android.widget.FrameLayout" resource-id="" text="" index="0">
<node bounds="[0,38][480,800]" selected="false" password="false" long-clickable="false" scrollable="false" focused="false" focusable="false" enabled="true" clickable="true" checked="false" checkable="false" content-desc="" package="com.UCMobile.intl" class="android.view.View" resource-id="" text="" index="0" NAF="true"/>
</node>
</hierarchy>
2。)试图查看任何资源id / text /任何特殊转储,以便我可以获得 元素和尝试点击但没有id / class / text是&#34;输入UC&#34;按钮。
如果您对此有任何建议,请与我们联系。
答案 0 :(得分:0)
UC浏览器使用自定义视图实现其UI(您可以从转储中看到),然后UiAutomator或类似工具无法深入了解其组件。< / p>
当时没有多少选择。您可以使用AndroidViewClient/culebra或CulebraTester在第一个屏幕上滑动,但到达最后一个屏幕时,您必须使用屏幕坐标触摸。
生成的脚本(在本例中为python,但您也可以生成java):
#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''
Copyright (C) 2013-2016 Diego Torres Milano
Created on 2017-05-06 by CulebraTester
__ __ __ __
/ \ / \ / \ / \
____________________/ __\/ __\/ __\/ __\_____________________________
___________________/ /__/ /__/ /__/ /________________________________
| / \ / \ / \ / \ \___
|/ \_/ \_/ \_/ \ o \
\_____/--<
@author: Diego Torres Milano
@author: Jennifer E. Swofford (ascii art snake)
'''
import re
import sys
import os
import unittest
try:
sys.path.insert(0, os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
pass
import pkg_resources
pkg_resources.require('androidviewclient>=12.4.0')
from com.dtmilano.android.viewclient import ViewClient, CulebraTestCase
from com.dtmilano.android.uiautomator.uiautomatorhelper import UiAutomatorHelper, UiScrollable, UiObject, UiObject2
TAG = 'CULEBRA'
class CulebraTests(CulebraTestCase):
@classmethod
def setUpClass(cls):
cls.kwargs1 = {'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False}
cls.kwargs2 = {'forceviewserveruse': False, 'useuiautomatorhelper': True, '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': 1, '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': False, '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.click(x=520, y=1603)
self.vc.sleep(_s)
if __name__ == '__main__':
CulebraTests.main()