自动点击特定元素
通过python调用adb命令实现用元素名称、id、class定位元素
http://blog.csdn.net/gb112211/article/details/33730221
方便查找对应元素特征
android sdk tools: uiautomatorviewer.bat
配置好android sdk后,cmd执行: uiautomatorviewer
自动输入中文
使用adb输入中文字符
http://blog.csdn.net/xiqobai/article/details/8204653
解决adb shell input text 中文输入,unicode转utf-8
http://blog.csdn.net/u011068616/article/details/47945927
按键操作
python arobot
UiAutomator 与 Shell 结合的力量
https://testerhome.com/topics/2806
解放双手——Android自动化测试
http://blog.csdn.net/eclipsexys/article/details/45622813
Android自动化测试(UiAutomator)简要介绍
通过python调用adb命令实现用元素名称、id、class定位元素
http://blog.csdn.net/gb112211/article/details/33730221
方便查找对应元素特征
android sdk tools: uiautomatorviewer.bat
配置好android sdk后,cmd执行: uiautomatorviewer
自动输入中文
使用adb输入中文字符
http://blog.csdn.net/xiqobai/article/details/8204653
解决adb shell input text 中文输入,unicode转utf-8
http://blog.csdn.net/u011068616/article/details/47945927
按键操作
python arobot
UiAutomator 与 Shell 结合的力量
https://testerhome.com/topics/2806
解放双手——Android自动化测试
http://blog.csdn.net/eclipsexys/article/details/45622813
Android自动化测试(UiAutomator)简要介绍
http://blog.csdn.net/chenbang110/article/details/23371597
示例:
do_weixin.py
#!/usr/bin/python
#coding:utf-8
from do_adb_click import *
from do_adb_arobot import *
# 到桌面
cmd = "input keyevent 3"
adbshellcommand(cmd)
# 自动发朋友圈
sendPYQ()
# 返回
cmd = "input keyevent 4"
adbshellcommand(cmd)
cmd = "input keyevent 4"
adbshellcommand(cmd)
do_adb_arobot.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# Android Robot 3.1
# This is a free software under GPL.
#
# Author: DiaoXuesong
# Bug report: wishcom@163.com
# ---------------------------------------------------------------------------
#
# Function:
# Screen cast via adb daemon, without java env.
# Usage:
# arobot.py [-option]
# Example:
# arobot.py
# arobot.py -lcd
# arobot.py -keypad
#
import subprocess, os
import threading
import socket, sys
import time
try:
import Tkinter as tk
import ttk
from PIL import Image, ImageTk, ImageDraw
except:
print 'Following module is needed:'
print '- Tkinter: sudo apt-get install python-tk'
print '- PIL: sudo apt-get install python-imaging-tk'
sys.exit()
# Set DEBUG to True if you need know more running message
DEBUG = False
# Set USE_TTK to False if you need classic Tk/Tcl GUI-style
USE_TTK = True
'''
Key value definition refer from KeyEvent.java
public class KeyEvent extends InputEvent implements Parcelable {
/** Key code constant: Unknown key code. */
public static final int KEYCODE_UNKNOWN = 0;
public static final int KEYCODE_SOFT_LEFT = 1;
public static final int KEYCODE_SOFT_RIGHT = 2;
public static final int KEYCODE_HOME = 3;
public static final int KEYCODE_BACK = 4;
public static final int KEYCODE_CALL = 5;
public static final int KEYCODE_ENDCALL = 6;
public static final int KEYCODE_0 = 7;
public static final int KEYCODE_1 = 8;
public static final int KEYCODE_2 = 9;
public static final int KEYCODE_3 = 10;
public static final int KEYCODE_4 = 11;
public static final int KEYCODE_5 = 12;
public static final int KEYCODE_6 = 13;
public static final int KEYCODE_7 = 14;
public static final int KEYCODE_8 = 15;
public static final int KEYCODE_9 = 16;
public static final int KEYCODE_STAR = 17;
public static final int KEYCODE_POUND = 18;
public static final int KEYCODE_DPAD_UP = 19;
public static final int KEYCODE_DPAD_DOWN = 20;
public static final int KEYCODE_DPAD_LEFT = 21;
public static final int KEYCODE_DPAD_RIGHT = 22;
public static final int KEYCODE_DPAD_CENTER = 23;
public static final int KEYCODE_VOLUME_UP = 24;
public static final int KEYCODE_VOLUME_DOWN = 25;
public static final int KEYCODE_POWER = 26;
public static final int KEYCODE_CAMERA = 27;
public static final int KEYCODE_CLEAR = 28;
public static final int KEYCODE_A = 29;
public static final int KEYCODE_B = 30;
public static final int KEYCODE_C = 31;
public static final int KEYCODE_D = 32;
public static final int KEYCODE_E = 33;
public static final int KEYCODE_F = 34;
public static final int KEYCODE_G = 35;
public static final int KEYCODE_H = 36;
public static final int KEYCODE_I = 37;
public static final int KEYCODE_J = 38;
public static final int KEYCODE_K = 39;
public static final int KEYCODE_L = 40;
public static final int KEYCODE_M = 41;
public static final int KEYCODE_N = 42;
public static final int KEYCODE_O = 43;
public static final int KEYCODE_P = 44;
public static final int KEYCODE_Q = 45;
public static final int KEYCODE_R = 46;
public static final int KEYCODE_S = 47;
public static final int KEYCODE_T = 48;
public static final int KEYCODE_U = 49;
public static final int KEYCODE_V = 50;
public static final int KEYCODE_W = 51;
public static final int KEYCODE_X = 52;
public static final int KEYCODE_Y = 53;
public static final int KEYCODE_Z = 54;
public static final int KEYCODE_COMMA = 55;
public static final int KEYCODE_PERIOD = 56;
public static final int KEYCODE_ALT_LEFT = 57;
public static final int KEYCODE_ALT_RIGHT = 58;
public static final int KEYCODE_SHIFT_LEFT = 59;
public static final int KEYCODE_SHIFT_RIGHT = 60;
public static final int KEYCODE_TAB = 61;
public static final int KEYCODE_SPACE = 62;
public static final int KEYCODE_SYM = 63;
public static final int KEYCODE_EXPLORER = 64;
public static final int KEYCODE_ENVELOPE = 65;
public static final int KEYCODE_ENTER = 66;
public static final int KEYCODE_DEL = 67;
public static final int KEYCODE_GRAVE = 68;
public static final int KEYCODE_MINUS = 69;
public static final int KEYCODE_EQUALS = 70;
public static final int KEYCODE_LEFT_BRACKET = 71;
public static final int KEYCODE_RIGHT_BRACKET = 72;
public static final int KEYCODE_BACKSLASH = 73;
public static final int KEYCODE_SEMICOLON = 74;
public static final int KEYCODE_APOSTROPHE = 75;
public static final int KEYCODE_SLASH = 76;
public static final int KEYCODE_AT = 77;
public static final int KEYCODE_NUM = 78;
public static final int KEYCODE_HEADSETHOOK = 79;
public static final int KEYCODE_FOCUS = 80;
public static final int KEYCODE_PLUS = 81;
public static final int KEYCODE_MENU = 82;
public static final int KEYCODE_NOTIFICATION = 83;
public static final int KEYCODE_SEARCH = 84;
public static final int KEYCODE_MEDIA_PLAY_PAUSE= 85;
public static final int KEYCODE_MEDIA_STOP = 86;
public static final int KEYCODE_MEDIA_NEXT = 87;
public static final int KEYCODE_MEDIA_PREVIOUS = 88;
public static final int KEYCODE_MEDIA_REWIND = 89;
public static final int KEYCODE_MEDIA_FAST_FORWARD = 90;
public static final int KEYCODE_MUTE = 91;
public static final int KEYCODE_PAGE_UP = 92;
public static final int KEYCODE_PAGE_DOWN = 93;
public static final int KEYCODE_PICTSYMBOLS = 94;
public static final int KEYCODE_SWITCH_CHARSET = 95;
public static final int KEYCODE_BUTTON_A = 96;
public static final int KEYCODE_BUTTON_B = 97;
public static final int KEYCODE_BUTTON_C = 98;
public static final int KEYCODE_BUTTON_X = 99;
public static final int KEYCODE_BUTTON_Y = 100;
public static final int KEYCODE_BUTTON_Z = 101;
public static final int KEYCODE_BUTTON_L1 = 102;
public static final int KEYCODE_BUTTON_R1 = 103;
public static final int KEYCODE_BUTTON_L2 = 104;
public static final int KEYCODE_BUTTON_R2 = 105;
public static final int KEYCODE_BUTTON_THUMBL = 106;
public static final int KEYCODE_BUTTON_THUMBR = 107;
public static final int KEYCODE_BUTTON_START = 108;
public static final int KEYCODE_BUTTON_SELECT = 109;
public static final int KEYCODE_BUTTON_MODE = 110;
public static final int KEYCODE_ESCAPE = 111;
public static final int KEYCODE_FORWARD_DEL = 112;
public static final int KEYCODE_CTRL_LEFT = 113;
public static final int KEYCODE_CTRL_RIGHT = 114;
public static final int KEYCODE_CAPS_LOCK = 115;
public static final int KEYCODE_SCROLL_LOCK = 116;
public static final int KEYCODE_META_LEFT = 117;
public static final int KEYCODE_META_RIGHT = 118;
public static final int KEYCODE_FUNCTION = 119;
public static final int KEYCODE_SYSRQ = 120;
public static final int KEYCODE_BREAK = 121;
public static final int KEYCODE_MOVE_HOME = 122;
public static fina