| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import uiautomator2 as u2
- import time
- from adbutils import adb
- from uiautomator2 import Direction
- d = u2.connect('127.0.0.1:6555') # 例如:"127.0.0.1:61468"
- # d = u2.connect_usb()
- print('>0>>>', d.info)
- res = d.shell('settings get global device_name')
- print('>>1>>', str(res.output).strip())
- #
- # el=d.xpath('//*[@content-desc="开仓"]').scroll_to(xpath='//*[@content-desc="市价全平"]', direction=Direction.FORWARD,
- # max_swipes=100)
- #
- # print('>>>>', el)
- #
- # while True:
- # time.sleep(9999)
- # d.xpath("//*[@text='私人FM']/../android.widget.ImageView")
- # d.screen_off();
- # d.sleep(4)
- # d.screen_on();
- # # d.keyevent('24')
- #
- # urls = ['https://www.baidu.com', 'https://www.qq.com']
- # idx = 0
- # for d in adb.device_list():
- # print('--->', d.serial) # print device serial
- # print('>>>', d.info) # print device
- # # d.open_browser(urls[idx])
- # idx += 1
- # d.switch_wifi(False)
- # ctx = d.dump_hierarchy()
- # print(f'>>{idx}>>', ctx)
- # pck = d.list_packages()
- # print(pck)
- # # d.switch_wifi(True)
- # # d.app_start("com.android.chrome")
- # img= d.screenshot()
- # img.save(f'screenshot{idx}.png')
- # print(img)
- # time.sleep(10)
- # d = adb.device(serial="127.0.0.1:50269")
- # print('>>1>', d.info) # print device
- #
- # # d.sleep = lambda seconds: d.shell(f'sleep {seconds}')
- # # d.sleep(3)
- # # print('>>2>', d.info) # print device
- #
- # w, h = d.window_size()
- # print('>>3>', w, h) # print device
- # # or
- # d = adb.device(transport_id=24) # transport_id can be found in: adb devices -l
- # You do not need to offer serial if only one device connected
- # RuntimeError will be raised if multi device connected
- # d = adb.device()
- # print('>>>',d.info)
|