Ejemplo n.º 1
0
 def post(self):
     platform = self.get_argument("platform").lower()
     device_url = self.get_argument("deviceUrl")
     id = str(uuid.uuid4())
     try:
         if platform == 'android':
             import uiautomator2 as u2
             d = u2.connect(device_url)
             d.platform = 'android'
             cached_devices[id] = d
         elif platform == 'ios':
             import atx
             d = atx.connect(device_url)
             cached_devices[id] = d
         else:
             import neco
             d = neco.connect(device_url or 'localhost')
             cached_devices[id] = d
     except Exception as e:
         self.set_status(430, "Connect Error")
         self.write({
             "success": False,
             "description": traceback.format_exc().encode('utf-8'),
         })
     else:
         self.write({
             "deviceId": id,
             'success': True,
         })
Ejemplo n.º 2
0
 def uninstall_all(self, device_ip=None):
     u = u2.connect(device_ip)
     u.app_uninstall_all(verbose=True)
Ejemplo n.º 3
0
 def unlock(self, device_ip=None):
     u = u2.connect(device_ip)
     u.unlock()
Ejemplo n.º 4
0
 def u2(self) -> u2.Device:
     device = u2.connect(self.serial)
     device.set_new_command_timeout(604800)
     return device
Ejemplo n.º 5
0
                dev.press("back")
                time.sleep(3)
            else:
                fail_times = fail_times + 1

                btn_close = d(textMatches='开心收下.*')
                btn_close.click_exists(timeout=1)
                logger.debug("{}没找到".format(action))

    return bfind_once


if __name__ == '__main__':
    try:
        u2.HTTP_TIMEOUT = 5
        d = u2.connect('192.168.1.102:5555')

        winsound.Beep(500, 200)

        #淘宝
        target_level = []
        target_level.append(Tofindobject('xpatch', \
            '//*[@resource-id="com.taobao.taobao:id/rv_main_container"]/android.widget.FrameLayout[2]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[11]'))

        #支付宝
        # target_level.append(Tofindobject('xpatch', \
        #     '//*[@resource-id="com.alipay.mobile.homefeeds:id/home_adbannerview"]/android.widget.RelativeLayout[1]'))

        target_level.append(Tofindobject('xpatch', '赚糖领红包'))

        max_count = 3
Ejemplo n.º 6
0
def cmd_start(args):
    d = u2.connect(args.serial)
    d.app_start(args.package_name)
Ejemplo n.º 7
0
def cmd_install(args):
    u = u2.connect(args.serial)
    pkg_name = u.app_install(args.url)
    print("Installed", pkg_name)
Ejemplo n.º 8
0
def cmd_screenshot(args):
    d = u2.connect(args.serial)
    d.screenshot().save(args.filename)
Ejemplo n.º 9
0
        MLog.info('app_foreground')
        self.start_app()
        pass

    def test_fps(self):
        MLog.info('start_fps')
        # self.start_app()  # 启动app
        # sleep(5)

        for i in range(0, 3):
            MLog.info('test repeat')
            self.ent_live()
            sleep(5)
            for j in range(0, 5):
                self.swipe_live()
                sleep(5)
            self.quit_live()
            sleep(5)
            self.app_background()
            sleep(5)
            self.app_foreground()
            sleep(5)
        self.stop_app()
        pass


if __name__ == '__main__':
    d = u2.connect()  # connect to device
    douyu = DouYu(d)
    douyu.test_fps()
Ejemplo n.º 10
0
class BaseView(object):
    def __init__(self, driver):
        self.driver = driver

    def find_element(self, *loc):
        return self.driver.find_element(*loc)

    def find_elements(self, *loc):
        return self.driver.find_elements(*loc)

    def get_window_size(self):
        return self.driver.get_window_size()

    def swipe(self, start_x, start_y, end_x, end_y, duration):
        return self.driver.swipe(start_x, start_y, end_x, end_y, duration)


if __name__ == '__main__':
    import uiautomator2 as u2

    d = u2.connect('10.0.2.15')
    print(d.info)
Ejemplo n.º 11
0
        self.d(resourceId="com.netease.cloudmusic:id/acm",
               className="android.widget.ImageView",
               instance=3).click()
        self.d(resourceId="com.netease.cloudmusic:id/t4").click()

    def next(self):
        self.d(resourceId="com.netease.cloudmusic:id/tu").click()

    def play(self):
        self.start()
        self.image()
        self.next()


class System():
    def __init__(self, d):
        self.d = d

    # 判断屏幕状态
    def screen(self):
        # 如果屏幕关闭
        if not self.d.info['screenOn']:
            self.d.screen_on()
        # self.d.swipe() 滑动解锁


if __name__ == '__main__':
    d = u2.connect('192.168.1.7')
    music = Music(d)
    music.play()
Ejemplo n.º 12
0
    '在吗', '还有吗', '多少钱', '租金', '房租', '多少', '哪一站', '多少平米', '多大', '月租', '合租',
    '坐标', '房源', '详细', '私聊', '位置', '单人', '双人', '有房子吗', '看房', '微信', '有没有', '什么价',
    '空房', '多钱', '在哪', '有房吗'
]
# 建立已发客户列表

customer_sended = [
    '游牧人Hiro', '走猫扛炮', '今天也不是好东西', 'SeasonWang_', '前门大鲤鱼', '李菲菲invicibility',
    '日兴小酱', '仙妮蒙', '猪居然', '龙猫不是不是不是猫', '小酒哥在东京_东京租房', '东京租赁买卖-柯南',
    'HarryPotter_DD', '黄艺伟', '蘇雲依Phoniex', '-桃子组阳酱-', '令和公主', '多元希', '葵记奶茶',
    '网路恶霸小猫驴', '两岁丢掉的牛', 'HilaryLFrankie', '七月_lan', '一起Superlit', '平成処女',
    '安德烈只钟意dollar', '小玉爱吃鱼cc', '嘉訢Michelle'
]
zhongjie_name = ['东京', '租']

d = u2.connect('127.0.0.1:62001')
print(d.info)


def page_down(content):
    d.swipe(163, 910, 330, 500)
    sleep(1)
    if d(resourceId="com.weico.international:id/item_timeline_toolbar_comment"
         ):

        if d(resourceId=
             "com.weico.international:id/item_timeline_toolbar_comment"
             ).get_text():
            number = int(
                d(resourceId=
                  "com.weico.international:id/item_timeline_toolbar_comment").
Ejemplo n.º 13
0
 def __init__(self, *args, **kwargs):
     unittest.TestCase.__init__(self, *args, **kwargs)
     #device id or device ip
     self.d = u2.connect('192.168.0.106')
Ejemplo n.º 14
0
def is_black():
    d = u2.connect()
    screen = d.info
    if not screen["screenOn"]:
        print("熄屏状态...")
        return True
Ejemplo n.º 15
0
        print("手机没连上")
    else:
        print("当前手机设备:%s" % str(devices))
        return devices[0]


def badpng(func):  #出错时截图装饰器
    @wraps(func)
    def wrapper(*args, **kwargs):
        start_time = time.time()
        try:
            func(*args, **kwargs)
        except:
            curtime = time.strftime("%Y%m%d-%H%M%S", time.localtime())
            d.screenshot('image\{}.png'.format(func.__name__ + '_' + curtime))
            print("异常函数:" + func.__name__ + '_' + curtime)
        end_time = time.time()
        execution_time = (end_time - start_time) * 1000
        print("time is %d ms" % execution_time)

    return wrapper


#feeec6d8
#devices_id=deviceslist()
#d = u2.connect(devices_id)

d = u2.connect('feeec6d8')
vova_android = 'com.vova.android'  #设备
vova_android = 'com.vova.android'  #设备
Ejemplo n.º 16
0
    def dConn(self, pid):
	    d = u2.connect(pid)
Ejemplo n.º 17
0
 def screenshot(self, device_ip, filename):
     u = u2.connect(device_ip)
     u.screenshot(filename)
Ejemplo n.º 18
0
def cmd_identify(args):
    d = u2.connect(args.serial)
    d.press("home")
    d.open_identify(args.theme)
Ejemplo n.º 19
0
 def healthcheck(self, device_ip):
     u = u2.connect(device_ip)
     u.healthcheck()
Ejemplo n.º 20
0
def cmd_healthcheck(args):
    d = u2.connect(args.serial)
    d.healthcheck()
Ejemplo n.º 21
0
 def set_driver(cls, dri):
     cls.d = u2.connect(dri)
Ejemplo n.º 22
0
def cmd_current(args):
    d = u2.connect(args.serial)
    print(json.dumps(d.current_app(), indent=4))
Ejemplo n.º 23
0
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import uiautomator2 as u2
from time import sleep
import extendevent

d = u2.connect('192.168.0.69')
print(d.info)
mouseID = extendevent.getmouseID(d)

d.app_start("org.openthos.filemanager")
# d(resourceId="org.openthos.filemanager:id/iv_setting").click()
sleep(2)
targeticon = d(text='桌面', className='android.widget.TextView')
extendevent.left_click(d, mouseID, targeticon)
targeticon = d(text='文档', className='android.widget.TextView')
extendevent.left_click(d, mouseID, targeticon)
targeticon = d(text='下载', className='android.widget.TextView')
extendevent.left_click(d, mouseID, targeticon)
targeticon = d(text='视频', className='android.widget.TextView')
extendevent.left_click(d, mouseID, targeticon)
targeticon = d(text='音乐', className='android.widget.TextView')
extendevent.left_click(d, mouseID, targeticon)
targeticon = d(text='图片', className='android.widget.TextView')
extendevent.left_click(d, mouseID, targeticon)
targeticon = d(resourceId='org.openthos.filemanager:id/file_path_grid')
extendevent.middle_click(d, mouseID, targeticon)
sleep(5)
d.app_stop("org.openthos.filemanager")
d.service("uiautomator").stop()
Ejemplo n.º 24
0
import uiautomator2 as u2
import time
import random

d = u2.connect()
info = d.info
print(info) # 1920 * 1080

screen_height = info.get('displayHeight')
screen_width = info.get('displayWidth')

def print_click(sx, sy, ex, ey, second):
    print(str(round(second, 2)) + '秒后拖拽(' + str(round(sx, 2)) + ', ' + str(round(sy, 2)) + '), 到(' +  str(round(ex, 2)) + ',' +  str(round(ey, 2)) + ')')

while 1:
    sx = random.uniform(20, screen_width / 3 * 2)
    sy = random.uniform(screen_height / 2, screen_height - 150)
    ex = random.uniform(20, screen_width / 3 * 2)
    ey = random.uniform(50, screen_height / 2)
    second = random.uniform(20, 40)
    print_click(sx, sy, ex, ey, second)
    time.sleep(second)
    steps = random.uniform(10, 30)
    d.swipe(sx, sy, ex, ey, steps)


Ejemplo n.º 25
0
# # -*- coding: utf-8 -*-
# import win32gui
# import win32api
# import win32con
# import time

#
# dr = webdriver.Firefox()
# dr.get('http://sahitest.com/demo/php/fileUpload.htm')
# upload = dr.find_element_by_id('file')
# upload.click()
# time.sleep(1)
# dialog = win32gui.FindWindow('#32770', u'文件上传')  # 对话框
# ComboBoxEx32 = win32gui.FindWindowEx(dialog, 0, 'ComboBoxEx32', None)
# ComboBox = win32gui.FindWindowEx(ComboBoxEx32, 0, 'ComboBox', None)
# Edit = win32gui.FindWindowEx(ComboBox, 0, 'Edit', None)  # 上面三句依次寻找对象,直到找到输入框Edit对象的句柄
# button = win32gui.FindWindowEx(dialog, 0, 'Button', None)  # 确定按钮Button
#
# win32gui.SendMessage(Edit, win32con.WM_SETTEXT, None, 'd:\\baidu.py')  # 往输入框输入绝对地址
# win32gui.SendMessage(dialog, win32con.WM_COMMAND, 1, button)  # 按button
# print (upload.get_attribute('value'))
import uiautomator2 as u2
d = u2.connect('HMK7N17309001642')
d.device_info
d.press("back")
import cv2
import numpy as np


Ejemplo n.º 26
0
import time
import uiautomator2 as u2

d = u2.connect()  # alias for u2.connect_wifi('10.0.0.1')
print(d.info)

for i in range(0, 111):
    # 向上滑动,获取下一个
    d(resourceId="com.ss.android.ugc.aweme:id/ayy").swipe("up", steps=20)

    # 点击分享按钮
    d(resourceId="com.ss.android.ugc.aweme:id/dbv").click()

    # 一次水平拖不到底
    # 多个水平滚动的
    d(className="android.support.v7.widget.RecyclerView",
      resourceId="com.ss.android.ugc.aweme:id/az",
      scrollable=True).fling.horiz.toEnd()
    d(className="android.support.v7.widget.RecyclerView",
      resourceId="com.ss.android.ugc.aweme:id/az",
      scrollable=True).fling.horiz.toEnd()

    # 点击复制
    d(text="复制链接").click()

    # 获取链接,好像有延时,所以
    time.sleep(0.3)
    with open("douyin.txt", "a+", encoding="utf8") as f:
        raw_url = d.clipboard
        f.write(raw_url + "\n")
        print(raw_url)
Ejemplo n.º 27
0
# click
import uiautomator2 as u2

d = u2.connect('192.168.5.231')

# click
d(text="Settings").click()

# long click
d(text="Settings").long_click()

# 等待元素的出现
d(text="Settings").wait(timeout=10.0)
d.implicitly_wait(10.0)
Ejemplo n.º 28
0
 def app_stop_all(self, device_ip=None):
     u = u2.connect(device_ip)
     u.app_stop_all()
Ejemplo n.º 29
0
 def __init__(self, device: str):
     """
     device: 如果是 USB 连接,则为 adb devices 的返回结果;如果是模拟器,则为模拟器的控制 URL 。
     """
     self.d = u2.connect(device)
     self.appRunning = False
Ejemplo n.º 30
0
 def identify(self, device_ip=None, theme='black'):
     u = u2.connect(device_ip)
     u.open_identify(theme)
Ejemplo n.º 31
0
 def setUpClass(cls):
     cls.d = u2.connect()
     cls.d.set_orientation('natural')
     cls.d.implicitly_wait(10)