Android自动化Appium--adb

adb在appium下可以使用一下6个操作:

1、text:支持输入文本内容(暂不支持中文)

2、keyevent:模拟按键

3、tap:点击

4、swipe:滑动

5、press:轨迹球按下

6、roll:轨迹球滚动

例如:
import os


class Input(object):

    # 输入文字
    def text(self, text):
        adb = 'adb shell input text %s' % text
        os.system(adb)

    # 滑动
    def swipe(self, x, y, x1, y1):
        adb = 'adb shell input swipe %s %s %s %s ' % (x, y, x1, y1)
        os.system(adb)

    # 模拟按键
    def keyevent(self, k):
        adb = 'adb shell input keyevent %s' % k
        os.system(adb)

    def tap(self, x, y):
        '''

        :param x:
        :param y:
        :return:
        '''
        adb = 'adb shell input tap %s %s' % (x,y)
        os.system(adb)


if __name__ == '__main__':
    adb = Input()
    # adb.text(1111)
    # adb.swipe(280, 720, 280, 240)
    # adb.keyevent(3)
    adb.tap(563,614)