adb 是PC和设备连接的桥梁,可以通过adb对devices进行相关操作
以上就是一些基本的adb 命令
在使用appium过程中,发现sendkeys和clear方法并不太好使,只好自己封装模拟手工一个一个删除
这里用到keyEvent,具体内容请参考api http://appium.github.io/java-client/
要删除一段文字,该怎么做:
1. 获取文本长度
2. 移动到文本最后
3. 按下删除按钮,直到和文本一样长度
移动到文本最后:123
删除:67
public static final int |
BACKSPACE |
67 |
public static final int |
DEL |
67 |
public static final int |
KEYCODE_MOVE_END |
123 |
实现代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
|
/** * This method for delete text in textView * * @author * @param */ public void clearText(String text) { driver.sendKeyEvent( 123 ); for ( int i = 0 ; i < text.length(); i++) { driver.sendKeyEvent( 67 );
} |
原文:http://www.cnblogs.com/snackguo/p/4945861.html