自动安装ucbrowser [英] Automate the installation of ucbrowser

查看:111
本文介绍了自动安装ucbrowser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试自动安装UC浏览器.我可以到达最后一个输入UC"按钮(在屏幕截图下面)按钮活动.我需要模拟单击"Enter UC"按钮的情况.

我尝试了多种方法(如下所列)来模拟点击,但没有解决问题.

1.)使用UIautomator dump-我试图获取转储并解析它以获得绑定,但是当我使用adb shell uiautomator dump获取转储时,我无法获得完整的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/文本/任何特殊转储,以便我可以获取 元素,然后尝试点击,但输入UC"按钮没有id/class/text.

如果您有任何建议,请告诉我.

解决方案

UC浏览器使用自定义视图(如您从转储中看到的)实现其UI,因此对于UiAutomator或类似应用程序是不可能的工具来了解其组成部分.

那时没有太多选择了.您可以使用 AndroidViewClient/culebra screenshot) button activity.I need to simulate the click on "Enter UC" button.

I tried multiple ways(listed below) to simulate the click but nothing worked out.

1.)Using UIautomator dump - I tried to fetch the dump and parse it to get the bound but when I am fetching the dump using adb shell uiautomator dump, I am not able to get the full complete UI hierarchy (maybe because it gives UI of only native view - I am not sure please let me know if you have any pointer).

Dump:

<?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.) Tried to see any resource id/ text / any special dump so that I can get the element and try tap but there is no id/class/text is there for "Enter UC" button.

Please let me know if you have any suggestions over it.

解决方案

UC Browser implements its UI with a custom View (as you can see from the dump) then it's not possible for UiAutomator or similar tools to get an insight of its components.

There are no many alternatives left then. You can use AndroidViewClient/culebra or CulebraTester to swipe through the first screens but when the last one is reached you should have to touch using screen coordinates.

The generated script (python in this case but you can also generate 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()

这篇关于自动安装ucbrowser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆