コード例 #1
0
def test_plugin(self):
    def _my_plugin(d, k):
        def _inner():
            return k

        return _inner

    u2.plugin_clear()
    u2.plugin_register('my', _my_plugin, 'pp')
    self.assertEqual(self.d.ext_my(), 'pp')
コード例 #2
0
 def setUpClass(cls):
     cls.d = u2.connect()
     ocr.API = "http://ocr.open.netease.com/api/ocr"
     u2.plugin_register("ocr", ocr.OCR)
     cls.d.set_orientation('natural')
     cls.d.healthcheck()
     cls.d.implicitly_wait(10)
     cls.d.app_clear("com.xiaoxiao.ludan")
     cls.d.app_stop_all()
     cls.NowTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
     cls.test_random = test_random_date()
     Case_DIR = os.path.abspath(os.path.dirname(__file__))
     cls.loanID_PATH = os.path.join(Case_DIR + "\\config\\loan_info.txt")
コード例 #3
0
def init():
    uiautomator2.plugin_register("xpath", XPath)
コード例 #4
0
ファイル: __init__.py プロジェクト: zxx1320/uiautomator2
        plt.plot(data['time'], data['cpu'], '-')
        plt.ylim(0, max(100, data['cpu'].max()))
        plt.ylabel('CPU')
        plt.gca().xaxis.set_major_formatter(ticker.NullFormatter())

        plt.subplot(3, 1, 3)
        plt.plot(data['time'], data['fps'], '-')
        plt.ylabel('FPS')
        plt.ylim(0, 60)
        plt.xlabel('Time')
        plt.savefig(os.path.join(target_dir, "summary.png"))


if __name__ == '__main__':
    import uiautomator2 as u2
    pkgname = "com.tencent.tmgp.sgame"
    # pkgname = "com.netease.cloudmusic"
    u2.plugin_register('perf', Perf, pkgname)

    d = u2.connect()
    print(d.app_current())
    # print(d.ext_perf.netstat(5350))
    # d.app_start(pkgname)
    d.ext_perf.start()
    d.ext_perf.debug = True
    try:
        time.sleep(500)
    except KeyboardInterrupt:
        d.ext_perf.stop()
        d.ext_perf.csv2images()
        print("threading stopped")
コード例 #5
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/3/26 10:40
# @Author  : gaoxudong
# @File    : jietu.py
# @Software: PyCharm
# coding: utf-8
import uiautomator2 as u2


class ScreenshotBase64(object):
    def __init__(self, d):
        self.d = d

    def screenshot_base64(self):
        import base64
        base64_data = base64.b64encode(self.d.screenshot(format='raw'))
        return base64_data


u2.plugin_register("screenshot_base64", ScreenshotBase64)

d = u2.connect('LNKREEMV99999999')
print(d.ext_screenshot_base64.screenshot_base64())