mirror of
https://mirror.skon.top/github.com/openatx/uiautomator2
synced 2026-04-21 05:13:27 +08:00
limit python version >= 3.8 use poetry instead of pbr, setup.py remove some useless deps add github.actions.test matrix, include mac, linux, windows (3.8-3.11) remove extra option [image] for pip install uiautomator[image]
30 lines
749 B
Python
30 lines
749 B
Python
# coding: utf-8
|
|
#
|
|
# GIL limit python multi-thread effectiveness.
|
|
# But is seems fine, because these operation have so many socket IO
|
|
# So it seems no need to use multiprocess
|
|
#
|
|
import threading
|
|
|
|
import adbutils
|
|
from logzero import logger
|
|
|
|
import uiautomator2 as u2
|
|
|
|
|
|
def worker(d: u2.Device):
|
|
d.app_start("io.appium.android.apis", stop=True)
|
|
d(text="App").wait()
|
|
for el in d.xpath("@android:id/list").child("/android.widget.TextView").all():
|
|
logger.info("%s click %s", d.serial, el.text)
|
|
el.click()
|
|
d.press("back")
|
|
logger.info("%s DONE", d.serial)
|
|
|
|
|
|
for dev in adbutils.adb.device_list():
|
|
print("Dev:", dev)
|
|
d = u2.connect(dev.serial)
|
|
t = threading.Thread(target=worker, args=(d,))
|
|
t.start()
|