appium用adb命令执行滑动操作

直接上代码 

def exe_adb(command):
    """
    执行一条adb命令
    :param command: 执行的命令
    :return: 执行结果
    """
    command_result = ''
    command_text = 'adb %s' % command
    results = os.popen(command_text, "r")
    try:
        while True:
            line = results.readline()
            if not line:
                break
            # print(line, end="")
            command_result += line
    except BaseException as e:
        print("command: %s exe fail..." % command)
        print(e)
    finally:
        results.close()
    return command_result


def swipe(start_x, start_y, end_x, end_y, count=1):
    """
    滑动
    :param start_x: 起始x
    :param start_y: 起始y
    :param end_x:   结束x
    :param end_y:   结束y
    :param count:   次数
    """
    for i in range(count):
        exe_adb(" shell input swipe %s %s %s %s 300" % (start_x, start_y, end_x, end_y))
        time.sleep(2)

 

你可能感兴趣的:(Appium自动化测试)