示例#1
0
    def __init__(self, serial=None, **kwargs):
        """Initial AndroidDevice
        Args:
            serial (str): serial or wlan ip

        Returns:
            AndroidDevice object

        Raises:
            EnvironmentError
        """
        self.__display = None
        serial = serial or getenvs('ATX_ADB_SERIALNO', 'ANDROID_SERIAL')
        self._host = kwargs.get('host') or getenvs(
            'ATX_ADB_HOST', 'ANDROID_ADB_SERVER_HOST') or '127.0.0.1'
        self._port = int(kwargs.get('port') or getenvs(
            'ATX_ADB_PORT', 'ANDROID_ADB_SERVER_PORT') or 5037)

        self._adb_client = adbkit.Client(self._host, self._port)
        self._adb_device = self._adb_client.device(serial)
        # self._adb_shell_timeout = 30.0 # max adb shell exec time

        # uiautomator2
        self._uiauto = uiautomator2.connect_usb(serial)
        if not self._uiauto.alive:
            self._uiauto.healthcheck(unlock=False)

        DeviceMixin.__init__(self)
        self._randid = base.id_generator(5)

        self.screen_rotation = None

        # inherts from atx-uiautomator
        self.swipe = self._uiauto.swipe
        self.drag = self._uiauto.drag
        self.press = self._uiauto.press
        self.long_click = self._uiauto.long_click
        self.dump = self._uiauto.dump_hierarchy
示例#2
0
# -*- coding:utf-8 -*-
"""
@Time   :2018/12/26 13:54
@Author :派森

本代码是使用xpath定位控件然后进行点击
速度理论上会比直接选择会快上许多
"""
import uiautomator2
import time

d = uiautomator2.connect_usb('7fb4dc26')

# 当前时间
now_time = time.localtime()

# 目标时间
target_time = time.strptime("2018-12-26 16:12:00", "%Y-%m-%d %H:%M:%S")

# 目标时间 减去当前时间 就是我们需要等待的时间
diff = (target_time.tm_hour - now_time.tm_hour) * 60 * 60 + (
    target_time.tm_min - now_time.tm_min) * 60 + (target_time.tm_sec -
                                                  now_time.tm_sec)

time.sleep(diff)

# 点击物品
# d(resourceId="com.taobao.taobao:id/tqg_goods_name").click()
d.xpath("//android.widget.TextView[@text='年货巧克力大礼包零食一整箱']").click()

# 点击立即购买
示例#3
0
    d.click(1849,112)
    new_sleep()

def random_num(x):
    return int(r(1,x))


def open_ditu():
    new_sleep()
    quyu_click(213,100,360,125)
    new_sleep()


    

d = u2.connect_usb('18bcc735')  #小米10青春版
# d = u2.connect_usb('113038e8') # 小米mix2
# d = u2.connect_usb('emulator-5554')
# d = u2.connect_adb_wifi("10.0.0.1:5555")

# d.click(5,5)

def click_youxiajiao():
    # x = 888
    # y = 2052
    x= 840 #~ 这里可以点击 关闭葫芦
    y = 2094
    d.click(x,y)


def get_file_content(filePath):
示例#4
0
#-*-coding:utf-8-*- 
__author__ = 'Administrator'

import uiautomator2 as u2
from atx.ext.chromedriver import ChromeDriver
from public import cofig

d = u2.connect_usb(cofig.ID)  #手机的ip 为10.10.23.15
d.app_start('com.github.android_app_bootstrap',stop='True')
d(text='Login').click()
d(text='Baidu').click()
driver = ChromeDriver(d).driver(cofig.ip2)  #这里也一样填手机的ip,端口5555即可
print("执行通过")
driver.find_element_by_id('index-kw').click()
driver.find_element_by_id('index-kw').send_keys('Python')
driver.find_element_by_id('index-bn').click()
print(driver.title)
driver.quit()
示例#5
0
 def __init__(self, *args):
     unittest.TestCase.__init__(self, *args)
     self.d = uiautomator2.connect_usb(
         self.get_item('Initialize settings', 'serial'))
     self.d.freeze_rotation()
     self.cycle = self.get_item(self.__class__.__name__, 'cycle number')
 def __init__(self, dbOper, httpOper, serial="6e0bc87e"):
     self.d = u2.connect_usb(serial=serial)
     self.dbOper = dbOper
     self.httpOper = httpOper
     self.password = "******"
     pass
示例#7
0
def toutiao(logger):
    # 引用Settings文件中的配置项
    device_settings = Devices()
    # 设备信息
    d = u2.connect_usb(device_settings.device)
    time.sleep(2)
    if not d.info['screenOn']:  # 监测屏幕是否休眠 如是则解锁点亮屏幕
        d.healthcheck()
    # 获取测试开始时间
    start_time = datetime.datetime.now()
    logger.info("今日头条开始时间: %s" % (str(start_time).split('.')[0]))
    a = time.time()
    b = a
    while b - a < 600:  # 设置运行时间大于 b - a 时跳出循环,其中b - a单位是秒
        try:
            if not d.info['screenOn']:  # 监测屏幕是否休眠 如是则解锁点亮屏幕
                d.healthcheck()
                time.sleep(2)
            d.press("home")
            # 打开微博
            d.app_start("com.ss.android.article.news")
            logger.info("启动了今日头条")
            time.sleep(10)
            # 必须要运行监测器
            d.watcher('Permission_a').when(text='允许').click()
            d.watcher('Permission_b').when(
                resourceId="com.sina.weibo:id/iv_close").click()
            d.watcher('Permission_i').when(text='不了,谢谢').click()
            d.watcher('Permission').when(text='以后再说').click(
                text='以后再说')  # 如果出现以后再说点击
            d.watcher("Permission_a").watched = True
            d.watcher("Permission_b").watched = True
            d.watcher("Permission_i").watched = True
            d.watcher("Permission").watched = True
            d.click(0.935, 0.135)
            time.sleep(2)
            d(text="关注").click()
            time.sleep(10)
            logger.info("开始滑动关注栏目")
            d.swipe(500, 1500, 500, 500)
            time.sleep(10)
            d.swipe(500, 1500, 500, 500)
            time.sleep(10)
            d.swipe(500, 500, 500, 1500)
            time.sleep(10)
            d.swipe(500, 500, 500, 1500)
            time.sleep(10)
            d.click(0.935, 0.135)
            time.sleep(2)
            d(text="深圳").click()
            time.sleep(10)
            logger.info("开始滑动深圳栏目")
            d.swipe(500, 1500, 500, 500)
            time.sleep(10)
            d.swipe(500, 1500, 500, 500)
            time.sleep(10)
            d.swipe(500, 500, 500, 1500)
            time.sleep(10)
            d.swipe(500, 500, 500, 1500)
            time.sleep(10)

            c = time.time()
            b = c

        except Exception as e:
            logger.error("今日头条元素定位出错!" + str(e))
            d.app_stop("com.ss.android.article.news")

    logger.info("今日头条新闻浏览结束")
    time.sleep(1)
    d.press("home")

    end_time = datetime.datetime.now()
    logger.info("本轮今日头条结束时间: %s" % (str(end_time).split('.')[0]))
    expend_time = end_time - start_time
    logger.info("本轮今日头条总共耗时:%s" % (str(expend_time).split('.')[0]))
示例#8
0
文件: test.py 项目: CJH01/PythonAPPUI
import uiautomator2 as ui2
from time import sleep
import serial
d = ui2.connect_usb('R58M36MWZ1B')
# d = ui2.connect_wifi('192.168.1.4')
# d.info
# print(d.window_size())
# print(d.serial)
# print(d.wlan_ip)
# print(d.device_info)
# print(d.app_info('com.govee.home'))
d.app_start('com.govee.home','com.govee.home.HomeActivity')
class Mytest():
    def __init__(self,mobileName,device,com, bps, timeout):
        #连接设备
        self.d = ui2.connect_usb(mobileName)
        #创建串口
        port = com
        bps = bps
        timeout = timeout
        global Ret
        try:
            # 打开串口,并得到串口对象
            main_engine = serial.Serial(port, bps, timeout=timeout)
            main_engine.flushInput()  # 清空缓冲区
            # 判断是否打开成功
            if (self.main_engine.is_open):
                Ret = True
        except Exception as e:
            print("---异常---:", e)
示例#9
0
# -*- coding: utf-8 -*-

import uiautomator2 as u2
import time
import os

img_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) + '/Uiautomator2/screenshots/'   #截图保持路径

d = u2.connect_usb('6e48b8db')

d.app_start("com.smile.gifmaker")

time.sleep(2)

d(resourceId="com.smile.gifmaker:id/left_btn").click()

time.sleep(1)

d(resourceId="com.smile.gifmaker:id/tv_game_center").click()

def tes_1(i):

    time.sleep(1)

    d(text="游戏").click()

    time.sleep(1)

    d(text="魔力转圈圈").click()

    time.sleep(1)
示例#10
0
# coding: utf-8
#

import unittest
from logzero import logger

import uiautomator2 as u2

# d = u2.connect_usb("3578298f")
d = u2.connect_usb()


class MusicTestCase(unittest.TestCase):
    def setUp(self):
        self.package_name = "com.netease.cloudmusic"
        d.ext_xpath.global_set({"timeout": 10})
        logger.info("setUp unlock-screen")
        # unlock screen
        # d.shell("input keyevent WAKEUP")
        d.screen_on()
        d.shell("input keyevent HOME")
        d.swipe(0.1, 0.9, 0.9, 0.1)  # swipe to unlock

    def runTest(self):
        logger.info("runTest")
        d.app_clear(self.package_name)
        s = d.session(self.package_name)
        s.set_fastinput_ime(True)

        xp = d.ext_xpath
        xp._d = s
示例#11
0
def weibotest(logger):
    # 引用Settings文件中的配置项
    device_settings = Devices()
    # 设备信息
    d = u2.connect_usb(device_settings.device)
    time.sleep(2)
    if not d.info['screenOn']:  # 监测屏幕是否休眠 如是则解锁点亮屏幕
        d.healthcheck()
    # 获取测试开始时间
    start_time = datetime.datetime.now()
    logger.info("微博开始时间: %s" % (str(start_time).split('.')[0]))
    a = time.time()
    b = a
    while b - a < 600:  # 设置运行时间大于 b - a 时跳出循环,其中b - a单位是秒
        try:
            if not d.info['screenOn']:  # 监测屏幕是否休眠 如是则解锁点亮屏幕
                d.healthcheck()
                time.sleep(2)
            d.press("home")
            # 打开微博
            d.app_start("com.sina.weibo")
            logger.info("启动了微博")
            time.sleep(10)
            # 必须要运行监测器

            d.watcher('Permission_b').when(
                resourceId="com.sina.weibo:id/iv_close").click()
            d.watcher('Permission_i').when(text='不了,谢谢').click()
            d.watcher('Permission').when(text='以后再说').click(
                text='以后再说')  # 如果出现以后再说点击

            d.watcher("Permission_b").watched = True
            d.watcher("Permission_i").watched = True
            d.watcher("Permission").watched = True

            d.xpath('//*[@content-desc="首页"]').click()
            time.sleep(1)
            # 点击推荐
            d.xpath('//*[@text="关注"]')
            logger.info("点击了关注")
            # time.sleep(2)
            logger.info("开始上下滑动")
            # 滑动操作
            d.swipe(500, 1500, 500, 500)
            time.sleep(15)
            d.swipe(500, 1500, 500, 500)
            time.sleep(15)
            d.swipe(500, 500, 500, 1500)
            time.sleep(15)
            d.swipe(500, 500, 500, 1500)
            time.sleep(15)
            d.press("home")

        except Exception as e:
            logger.error("微博元素定位出错!" + str(e))
            d.app_stop("com.sina.weibo")
        c = time.time()
        b = c
        time.sleep(1)
        d.press("home")

    end_time = datetime.datetime.now()
    logger.info("本轮微博结束时间: %s" % (str(end_time).split('.')[0]))
    expend_time = end_time - start_time
    logger.info("本轮微博总共耗时:%s" % (str(expend_time).split('.')[0]))
示例#12
0
# _*_ coding:utf-8 _*_

__author__ = 'bobby'
__date__ = '2018/10/8 11:19'
import uiautomator2 as u2
import time

# d = u2.connect('172.20.157.7')
# d = u2.connect_usb('810EBM32TZ4K')
d = u2.connect_usb('127.0.0.1:52025')
# d.adb_shell('am start -n com.example.hellworldtest/.MainActivity')
# # d(text=u"hellworldtest", description=u"hellworldtest", className="android.widget.TextView").click()
# time.sleep(3)
# d(description=u"aaaaaa", className="android.view.View").click()
# time.sleep(3)
# d(description=u"Link Blog", className="android.view.View").click()
# time.sleep(3)
num = 1
while True:

    try:
        d.adb_shell("am force-stop com.ahdi.qrindo.mydwallet")
        time.sleep(3)
        d.adb_shell(
            'am start -n com.ahdi.qrindo.mydwallet/com.ahdi.wallet.ui.activities.LoginActivity'
        )
        # d(text=u"My DISRUPTO").click()
        time.sleep(5)
        #
        # # d(resourceId="com.ahdi.qrindo.mydwallet:id/et_login_phone_number").send_keys("81122336666")
        # # d(resourceId="com.ahdi.qrindo.mydwallet:id/et_login_pwd").send_keys("abc123456")
                    break
                else:
                    if index == len(result) - 1:
                        result.append(pt)
        else:
            result.append(pt)
    print(result)
    for p in result:
        cv2.rectangle(img, (p[0], p[1]), (p[0] + w, p[1] + h), (0, 0, 255), 3)
    cv2.imwrite('./temp/{} of {}'.format(meth, pic_name), img)
    return result


if __name__ == '__main__':
    # pp = uiautomator2.connect_usb('8DF6R16729018868')
    pp = uiautomator2.connect_usb('0071ea56')
    # print(pp.window_size())
    pp.screenshot("home.jpg")

    imsrc = cv2.imread('home.jpg')
    # img_gray = cv2.cvtColor(imsrc, cv2.COLOR_BGR2GRAY)
    img_big = imsrc.copy()
    pic_files = os.listdir('./pic')
    for pic_name in pic_files:
        im_small = cv2.imread(os.path.join('./pic', pic_name))
        methods = [ 'cv2.TM_CCOEFF_NORMED']
        # methods = ['cv2.TM_CCORR_NORMED']
        for meth in methods:
            print('Parent process %s.' % os.getpid())
            p = Process(target=match_pic, args=(img_big, im_small, meth, pic_name))
            print('Child process will start.')
示例#14
0
文件: unlock.py 项目: Ghello8/Github
import uiautomator2
d = uiautomator2.connect_usb()


def unlock():
    d.swipe(0.474, 0.841, 0.474, 0.363)
    d.click(0.212, 0.534)
    d.click(0.762, 0.723)
    d.click(0.763, 0.628)
    d.click(0.225, 0.729)
示例#15
0
 def setUpClass(cls):
     cls.d = u2.connect_usb()
     cls.d.set_orientation('natural')
     cls.d.implicitly_wait(10)
示例#16
0
文件: main.py 项目: Hijiao/QA-Helper
# coding=utf-8
import os
from PIL import Image
import time
from ocr import recognize
from selenium import webdriver

import uiautomator2 as u2

d = u2.connect_usb()

origin_dir = 'img/'
if not os.path.isdir(origin_dir):
    os.mkdir(origin_dir)

img_ext = ''


def pull_screenshot(mission):
    img_path = '/sdcard/DCIM/{}{}.png'.format(img_ext, mission)
    os.system('adb shell screencap -p {}'.format(img_path))
    os.system('adb pull {} {}'.format(img_path, origin_dir))


if __name__ == '__main__':
    browser = webdriver.Firefox()
    url = "http://www.baidu.com"
    browser.get(url)
    while True:
        flag = raw_input("come on~\n")
        start = time.time()
示例#17
0
 def setUpClass(cls):
     cls.u = u2.connect_usb(cofig.ID)
     cls.u.healthcheck()  # 解锁屏幕并启动uiautomator服务
     #hrp = htmlreport.HTMLReport(cls.u, 'report')
     #hrp.patch_click()
     cls.u.make_toast("测试开始")
示例#18
0
def collection(serial, douyin_hao):
    os.system(f'python -m uiautomator2 init --serial {serial}')
    d = u2.connect_usb(serial)
    while True:
        if enter(d, douyin_hao):
            break
        continue
    redis_client = redis.Redis(host='148.70.86.158', password='******')
    fen_set = set()
    guan_set = set()

    while True:
        try:
            ui_str = d.dump_hierarchy()
            if '本场榜' in ui_str:
                d.press("back")
                time.sleep(1)
            if '搜索' in ui_str:
                # d.xpath(
                # 		'//android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.support.v4.view.ViewPager/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.support.v7.widget.RecyclerView/android.widget.LinearLayout/android.widget.LinearLayout/android.support.v7.widget.RecyclerView/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.ImageView').click()
                d.xpath(
                    '//android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.support.v4.view.ViewPager/android.widget.LinearLayout/android.widget.FrameLayout/android.view.View/android.support.v7.widget.RecyclerView/android.widget.LinearLayout/android.widget.LinearLayout/android.support.v7.widget.RecyclerView/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.ImageView'
                ).click()
            if '直播已结束' in ui_str:
                loggin.info('直播已结束...')
                d.press("home")
                break
            if '立即赠送' in ui_str:
                d.press("back")
                time.sleep(1)
            if '条新消息' in ui_str:
                d.click(115, 1308)
                time.sleep(3)
            if '说点什么...' not in ui_str and '说点什么' in ui_str:
                d.press("back")
                time.sleep(1)
            if '@TA' in ui_str:
                d.press("back")
                time.sleep(1)
            #欢迎
            dd = d.xpath(
                '//android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView'
            ).all()
            if dd:
                text_1 = dd[0].text
                if text_1:
                    redis_client.lpush(f'robot:text:{douyin_hao}',
                                       f"欢迎{text_1}")
            ddd = d.xpath(
                '//android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.support.v7.widget.RecyclerView/android.widget.RelativeLayout/android.widget.TextView'
            ).all()
            if ddd:
                for dddd in ddd:
                    text = dddd.text

                    if '送出' in text:
                        if '嘉年华' in text or '抖音1号' in text or '直升机' in ui_str or '独角兽' in ui_str or '爱心光波枪' in ui_str:
                            for _ in range(3):
                                redis_client.lpush(
                                    f'robot:text:{douyin_hao}',
                                    f"感谢{text.strip('0 ').split(': 送出')[0]}送的礼物"
                                )
                        elif 'Disco' in ui_str:
                            for _ in range(2):
                                redis_client.lpush(
                                    f'robot:text:{douyin_hao}',
                                    f"感谢{text.strip('0 ').split(': 送出')[0]}送的礼物"
                                )
                        else:
                            redis_client.lpush(
                                f'robot:text:{douyin_hao}',
                                f"感谢{text.strip('0 ').split(': 送出')[0]}送的礼物")

                    if '关注了主播' in text:
                        # TODO
                        guan_name = text.strip('0 ').split('关注了主播')[0]
                        if guan_name not in guan_set:
                            guan_set.add(guan_name)
                            redis_client.lpush(f'robot:text:{douyin_hao}',
                                               f"感谢{guan_name}的关注")
                            continue
                    if '分享本次直播' in text:
                        fen_name = text.strip('0 ').split('分享本次直播')[0]
                        if fen_name not in fen_set:
                            fen_set.add(fen_name)
                            redis_client.lpush(f'robot:text:{douyin_hao}',
                                               f"感谢{fen_name}的分享")
                            continue

        except Exception as e:
            logging.info(f'ERROR:{e}')
            pass
示例#19
0
 def __init__(self):
     self.name = util.get_device_name_from_usb()
     self.d = u2.connect_usb(self.name)
     if not self.d:
         self.d = u2.connect()  # 连接设备
     pass
示例#20
0
        self._qutoutiao.qutoutiao()

    def exec_douyin(self):
        self._douyin.douyin()

    def exec_wanqia(self):
        if not self._wanqia_success:
            self._wanqia_success = self._wanqia.wanqia()

    def stop_all_apps(self):
        self._operator.close_all_app()


if __name__ == '__main__':
    device_id = 'JGB9K17A18908832'
    d = u2.connect_usb(device_id)
    task = Task(d)
    wanqia_success = False
    while True:
        if 0 < get_hour() < 7:
            if get_minute() < 20:
                task.exec_wanqia()
            sleep(60)
            continue
        if get_minute() < 10:
            task.exec_douyin()
        elif get_minute() < 20:
            task.exec_shuabao()
        if get_minute() < 40:
            task.exec_douyin()
        elif get_minute() < 50:
示例#21
0
def main_run(phone_serial):
    """ 用来测试的乐视X620手机序列号是    LE67A06150003303   """
    pp = uiautomator2.connect_usb(phone_serial)
    time.sleep(1)
    while not pp(resourceId='android:id/content').exists:
        pp.unlock()
        time.sleep(1)
        pp.screen_on()
    print(pp.address)

    # 测试代码部分

    # 重置电池状态
    # pp.shell('dumpsys battery reset')
    # raise

    # 禁用USB充电
    pp.shell('dumpsys battery set usb 0')
    # 设置电池电量
    pp.shell(f'dumpsys battery set level {random.randint(15, 95)}')
    # 设置电池为非充电状态
    pp.shell('dumpsys battery set status 1')

    # 调用系统应用,清理缓存和垃圾
    # CleanCash(pp).main_do()
    # 清理多余占用内存的APP
    CleanCash(pp).app_init()

    # 低收益app: 天天爱清理,米读,快音,小糖糕, 彩蛋,趣铃声
    # 大部分APP都是前面刷的快,后面慢

    # 程序开始运行,开始APP任务
    t = time.time()
    job_list = [i for i in range(100)]
    # 随机执行
    random.shuffle(job_list)
    for k in job_list:
        if k == -1:
            continue
        elif k == 0:
            JinDong(phone_serial, pp).recycle_main_do(target_coin=8000)
        elif k == 1:
            JinRiTouTiao(phone_serial, pp).recycle_main_do(target_coin=6500)
        elif k == 2:
            QuTouTiao(phone_serial, pp).recycle_main_do(target_coin=7000)
        elif k == 3:
            HuiTouTiao(phone_serial, pp).recycle_main_do(target_coin=5000)
        elif k == 4:
            CaiDan(phone_serial, pp).recycle_main_do(target_coin=3000)
        # elif k == 5:
        #     QuLingSheng(phone_serial, pp).recycle_main_do(target_coin=1200)
        elif k == 6:
            ShuaBao(phone_serial, pp).recycle_main_do(target_coin=6000)
        # elif k == 7:
        # 这个APP特别卡,没有今日金币获取地方,在看视频过程中还有滑块验证
        # WeiShi(phone_serial, pp).recycle_main_do(target_coin=1000)
        elif k == 8:
            HuoShan(phone_serial, pp).recycle_main_do(target_coin=3000)
        # elif k == 9:
        #     DouYin(phone_serial, pp).recycle_main_do(target_coin=2000)
        elif k == 10:
            KuaiShou(phone_serial, pp).recycle_main_do(target_coin=6000)
        # elif k == 11:
        #     XiangKan(phone_serial, pp).recycle_main_do(target_coin=1000)
        # elif k == 12:
        #     MiDu(phone_serial, pp).recycle_main_do(target_coin=1000)
        # elif k == 13:
        #     XiaoTangGao(phone_serial, pp).recycle_main_do(target_coin=2000)
        # elif k == 14:
        #     KuaiYin(phone_serial, pp).recycle_main_do(target_coin=2000)
        # elif k == 15:
        #     TianTianAiQingLi(phone_serial, pp).recycle_main_do(target_coin=2000)
        elif k == 16:
            # 这个注册时候账号异常,客服说不影响使用,但是被系统检测到了,尝试了下,可以获得金币,提现还在测试
            ShanDianHezi(phone_serial, pp).recycle_main_do(target_coin=80000)
        # elif k == 17:
        #     WeiLiKanKan(phone_serial, pp).recycle_main_do(target_coin=2000)
        elif k == 18:
            HongBaoShiPin(phone_serial, pp).recycle_main_do(target_coin=7000)
        # elif k == 19:
        # 这个收益太低,10万换1元
        # SouHuZiXun(phone_serial, pp).recycle_main_do(target_coin=70000)
        elif k == 20:
            MoFangKanDian(phone_serial, pp).recycle_main_do(target_coin=4000)
        else:
            continue

        pp.shell(f'dumpsys battery set level {random.randint(15, 95)}')
        CleanCash(pp).app_init()
        if time.time() - t > 50000:
            break

    # 调用系统应用,清理缓存和垃圾
    CleanCash(pp).main_do()
    # 重置电池状态
    pp.shell('dumpsys battery reset')
示例#22
0
import sys 

sys.path.append('../')
from fast_screenshot import jiepin

from time import sleep 
from comm import isMove,isMove_once,isFight_once,get_random_num,get_09,open_ditu,quyu_jietu

import aircv as ac



# d = u2.connect_wifi('192.168.205.180')
# d = u2.connect_adb_wifi("10.0.0.1:5555")

d = u2.connect_usb('DLQ0216505001224')

def get_file_content(filePath):
    with open(filePath, 'rb') as fp:
        return fp.read()

  
#^ 找图函数
def matchImg(imgsrc,imgobj,confidencevalue=0.8):#imgsrc=原始图像,imgobj=待查找的图片
    sleep(0.2)
    try:      
        imsrc = ac.imread(imgsrc)
    except:
        sleep(1)
        imsrc = ac.imread(imgsrc)
        
示例#23
0
    def __init__(self, deviceName):
        self.deviceName = deviceName
        self.sanxing6 = "5203adddfc7334c1"
        self.yijia7 = "4e62be76"
        self.d = u2.connect_usb(self.deviceName)
        self.homeActivity = "com.qisi.ikeyboarduirestruct.NavigationActivityNew"
        self.interstitialActivity = "com.qisi.ui.InterstitialActivity"
        self.gmsAdActivity = "com.google.android.gms.ads.AdActivity"

        self.Space = [0.548, 0.909]
        self.Sugg = [0.4, 0.637]
        self.sanxing6_a = [0.098, 0.781]
        self.sanxing6_b = [0.598, 0.873]
        self.sanxing6_c = [0.400, 0.840]
        self.sanxing6_d = [0.305, 0.783]
        self.sanxing6_e = [0.251, 0.7]
        self.sanxing6_f = [0.401, 0.779]
        self.sanxing6_g = [0.508, 0.789]
        self.sanxing6_h = [0.622, 0.784]
        self.sanxing6_i = [0.748, 0.697]
        self.sanxing6_j = [0.694, 0.784]
        self.sanxing6_k = [0.799, 0.789]
        self.sanxing6_l = [0.901, 0.783]
        self.sanxing6_m = [0.808, 0.865]
        self.sanxing6_n = [0.706, 0.872]
        self.sanxing6_o = [0.85, 0.69]
        self.sanxing6_p = [0.943, 0.699]
        self.sanxing6_q = [0.047, 0.7]
        self.sanxing6_r = [0.356, 0.699]
        self.sanxing6_s = [0.194, 0.786]
        self.sanxing6_t = [0.452, 0.7]
        self.sanxing6_u = [0.652, 0.697]
        self.sanxing6_v = [0.497, 0.872]
        self.sanxing6_w = [0.155, 0.699]
        self.sanxing6_x = [0.296, 0.868]
        self.sanxing6_y = [0.556, 0.704]
        self.sanxing6_z = [0.197, 0.867]

        self.yijia7_a = [0.094, 0.766]
        self.yijia7_b = [0.602, 0.84]
        self.yijia7_c = [0.397, 0.842]
        self.yijia7_d = [0.299, 0.764]
        self.yijia7_e = [0.255, 0.697]
        self.yijia7_f = [0.397, 0.769]
        self.yijia7_g = [0.514, 0.768]
        self.yijia7_h = [0.605, 0.774]
        self.yijia7_i = [0.755, 0.7]
        self.yijia7_j = [0.704, 0.771]
        self.yijia7_k = [0.802, 0.771]
        self.yijia7_l = [0.89, 0.768]
        self.yijia7_m = [0.799, 0.842]
        self.yijia7_n = [0.7, 0.838]
        self.yijia7_o = [0.85, 0.695]
        self.yijia7_p = [0.952, 0.702]
        self.yijia7_q = [0.051, 0.704]
        self.yijia7_r = [0.354, 0.7]
        self.yijia7_s = [0.204, 0.771]
        self.yijia7_t = [0.456, 0.7]
        self.yijia7_u = [0.645, 0.697]
        self.yijia7_v = [0.51, 0.842]
        self.yijia7_w = [0.153, 0.692]
        self.yijia7_x = [0.291, 0.84]
        self.yijia7_y = [0.543, 0.699]
        self.yijia7_z = [0.193, 0.842]
示例#24
0
    def login_app(self, package):
        try:
            if package.name == "com.homelink.im":
                d = u2.connect_usb(self.sn)
                d.app_start("com.homelink.im")
                d(resourceId="com.lianjia.link.plugin:id/et_username"
                  ).set_text(package.usr_id)
                d(resourceId="com.lianjia.link.plugin:id/et_password"
                  ).set_text(package.usr_pwd)
                sleep(2)
                d.press("back")
                d(resourceId="com.lianjia.link.plugin:id/btn_login").click()

                if d.exists(
                        resourceId="com.lianjia.link.plugin:id/et_auth_code"):
                    print "get code"
                    code = get_code(id)
                    d(resourceId="com.lianjia.link.plugin:id/et_auth_code"
                      ).set_text(code)
                    sleep(2)
                    d.press("back")
                    d(resourceId="com.lianjia.link.plugin:id/btn_login").click(
                    )
            # elif package.name == "com.cmcm.shorts":
            #     cmd = "adb -s {} shell am start -n com.cmcm.shorts/com.cmcm.cmlive.activity.SplashActivity".format(self.sn)
            #     timeout_command.run(cmd)
            #     time.sleep(10)
            #     d = Device('{}'.format(self.sn))
            #
            #     click_premission(d)
            #     d(resourceId="com.cmcm.shorts:id/home_bottom_user").click()
            #     d(resourceId="com.cmcm.shorts:id/layout_login_second").click()
            #     click_premission(d)
            #     d(text="Guoliang Ren").click()
            #     click_premission(d)
            #     time.sleep(15)
            #     d.press.home()
            # elif package.name == "com.cmcm.live":
            #     cmd = "adb -s {} shell am start -n com.cmcm.live/com.cmcm.cmlive.activity.SplashActivity".format(self.sn)
            #     timeout_command.run(cmd)
            #     time.sleep(10)
            #     d = Device('{}'.format(self.sn))
            #     click_premission(d)
            #     d(resourceId="com.cmcm.live:id/layout_login_fifth").click()
            #     d(resourceId="com.cmcm.live:id/id_google_plus").click()
            #     click_premission(d)
            #     d(text="Guoliang Ren").click()
            #     time.sleep(10)
            #     click_premission(d)
            #     d.press.home()
            # elif package.name == "com.cmcm.textone":
            #     cmd = "adb -s {} shell am start -n com.cmcm.textone/com.yy.iheima.startup.SplashActivity".format(self.sn)
            #     timeout_command.run(cmd)
            #     time.sleep(15)
            #     d = Device('{}'.format(self.sn))
            #     d(resourceId="com.cmcm.textone:id/googleView").click()
            #     d(text="Guoliang Ren").click()
            #     time.sleep(20)
            #     d.press.home()
            # elif package.name == "panda.keyboard.emoji.theme":
            #     cmd = "adb -s {} shell am start -n panda.keyboard.emoji.theme/cmcm.wizard.SetupActivity".format(self.sn)
            #     timeout_command.run(cmd)
            #     time.sleep(8)
            #     d = Device('{}'.format(self.sn))
            #     d.click(770, 2100)
            #     time.sleep(2)
            #     d.press.back()
            #     time.sleep(2)
            #     d(text=' Cheetah Keyboard ❤ ❤ ❤ ').click()
            #     d(text='OK').click()
            #     d(text='OK').click()
            #     time.sleep(5)
            #     d.click(770, 2100)
            #     d(text=' Cheetah Keyboard ❤ ❤ ❤ ').click()
            #     time.sleep(5)
            #     click_premission(d)
            #     d.press.back()
            #     d.press.back()
            #     d.press.back()
            # else :
            #     logging.info("Don't need login")
        except Exception as e:
            logging.debug(e)
            logging.error("login fail")
示例#25
0
 def __init__(self):
     self.d = u2.connect_usb('A1CEBNA227ZK')
     self.d.click_post_delay = 1.5
     Testreport = htmlreport.HTMLReport(self.d)
     Testreport.patch_click()
示例#26
0
import datetime
import uiautomator2 as ut2
import allure
import pytest
import config
import time
import conftest
d = ut2.connect_usb(config.device_name)


#28826 主图画面“比例尺”按钮缩放
def test_scale_28826():
    time.sleep(1)
    while d(resourceId="com.ecarx.adnavi:id/map_search").wait() is not True:
        d.press("back")
    d(resourceId="com.ecarx.adnavi:id/scale_reduce").click()
    d(resourceId="com.ecarx.adnavi:id/scale_reduce").click()
    d(resourceId="com.ecarx.adnavi:id/scale_reduce").click()
    d(resourceId="com.ecarx.adnavi:id/scale_reduce").click()
    d(resourceId="com.ecarx.adnavi:id/scale_reduce").click()
    while d(resourceId="com.ecarx.adnavi:id/scale_title").get_text(
    ) not in "200米":
        d(resourceId="com.ecarx.adnavi:id/scale_add").click()
    d(resourceId="com.ecarx.adnavi:id/scale_add").click()
    assert d(resourceId="com.ecarx.adnavi:id/scale_title").get_text() in "100米"
    d(resourceId="com.ecarx.adnavi:id/scale_add").click()
    assert d(resourceId="com.ecarx.adnavi:id/scale_title").get_text() in "50米"
    d(resourceId="com.ecarx.adnavi:id/scale_reduce").click()
    assert d(resourceId="com.ecarx.adnavi:id/scale_title").get_text() in "100米"
    d(resourceId="com.ecarx.adnavi:id/scale_reduce").click()
    assert d(resourceId="com.ecarx.adnavi:id/scale_title").get_text() in "200米"
示例#27
0
 def __init__(self):
     self.d = u2.connect_usb('UHESY7W6NH')
     self.d.app_start('com.ss.android.ugc.aweme')
示例#28
0
import uiautomator2 as u2

d = u2.connect_usb('be1bd33f')

import time

d(resourceId="com.bbk.launcher2:id/item_icon", className="android.widget.ImageView", instance=8).click()
time.sleep(5)

d(resourceId="com.pujitech.pujiejia:id/fixed_bottom_navigation_icon", description=u"icon", className="android.widget.ImageView", instance=3).click()

time.sleep(3)


d(resourceId="com.pujitech.pujiejia:id/tv_wallet").click()

time.sleep(3)


d(resourceId="com.pujitech.pujiejia:id/my_wallet_yue_shuoming_tv").click()

time.sleep(3)

d(resourceId="com.pujitech.pujiejia:id/iv_back").click()

time.sleep(3)

d(resourceId="com.pujitech.pujiejia:id/my_wallet_qu_chongzhi_btn").click()


time.sleep(3)
示例#29
0
 def setUpClass(cls):
     cls.d = u2.connect_usb()
示例#30
0
#!/usr/bin/python
# coding:utf-8

import uiautomator2 as u2
import xml.etree.ElementTree as ET
import time
import re
from version import *

# d = u2.connect('192.168.0.100')
# d = u2.connect_usb('1208ceba')
d = u2.connect_usb('c176b27d')
# d.disable_popups()
DEBUG = False
d.freeze_rotation()
size = d.window_size()


HEIGHT = size[1]
WIDTH = size[0]
BOTTON = 2214


# 检测到的手机名称
udid = d.device_info["udid"]
# 设备名称
vivoX7 = "c176b27d-18:e2:9f:2e:dd:78-vivo_X7Plus"
vivoX23 = "c176b27d-18:e2:9f:2e:dd:78-vivo_X23Plus"


Element = version["7.0.0"]
示例#31
0
    time.sleep(5)
    d.xpath(
        '//*[@resource-id="app"]/android.view.View[1]/android.view.View[3]/android.view.View[9]'
    ).click()
    load_dict = tiaozhandati.loadanswer() + tiaozhandati.loadunknown()
    for i in range(0, count):
        d.xpath('//*[@text="开始比赛"]').click()
        time.sleep(4)
        if d.xpath('//*[@text="知道了"]').exists:
            d.xpath('//*[@text="知道了"]').click()
            return -1
        unknown = zsydati(d, load_dict, answer_delay)
        if len(unknown) > 0:
            print(unknown)
        time.sleep(random.randint(delay_min, delay_max))
        if len(unknown) > 0:
            data = unknown + tiaozhandati.loadunknown()
            with open("unknown.json", 'w', encoding='utf-8') as f:
                json.dump(data, f, ensure_ascii=False, indent=4)
            time.sleep(20)
            print("生成题库完成")

    d.xpath('//*[@text=""]').click()
    time.sleep(2)
    return count


if __name__ == '__main__':
    d = u2.connect_usb('emulator-5554')
    zsy(d, count=30, answer_delay=0.78, delay_max=8, delay_min=5)
示例#32
0
 def setUpClass(cls):
     cls.u = u2.connect_usb()
     # cls.u.healthcheck()  # 解锁屏幕并启动uiautomator服务
     # cls.u.disable_popups(True)  # 允许自动处理弹出框
     cls.u.make_toast("测试开始", 3)
示例#33
0
import uiautomator2 as u2
import time
import random

d = u2.connect_usb('7bff6865')
d.app_start('com.pingan.idle.redmahjong')
#d.unlock()
print(d.healthcheck())
print(d.current_app())
print(d.current_app().get('package'))
time.sleep(5)
d.click(0.669, 0.725)
# count = 0
# flag = True
# while(flag):
#     a = round(random.uniform(0,1),3)
#     b = round(random.uniform(0,1),3)
#     d.click(a,b)
#     if d.current_app().get('package') != 'com.pingan.idle.redmahjong':
#         flag = False
#     count += 1
#     if count > 10000:
#         flag = False
# print(d.current_app().get('package'))
# print(count)
# print('==========退出============')
xml = d.dump_hierarchy()
print(xml)