码迷,mamicode.com
首页 > 移动开发 > 详细

Android测试之Keycode

时间:2014-11-25 01:41:59      阅读:593      评论:0      收藏:0      [点我收藏+]

标签:android   blog   http   io   ar   os   使用   sp   java   

问题:

昨天做测试Case,发现一个网游APK运行界面,uiautomator无法捕捉获取。

因而输入的时候只得运用(dut.onclick(int a, int y))坐标点击的方法来输入用户名和密码。

既无法具有屏幕的适应性,也使得输入代码繁杂,容易出错。

 

解决方法: 使用 UiDevice.getInstance().pressKeyCode(int x)方法

 

	String id="inteltest";
			for(int i=0;i<id.length();i++){
				char c =id.charAt(i);
				if(c >=48&&c <=57){
				UiDevice.getInstance().pressKeyCode(c-41);
				}
				else
					if(c >=97&&c <=122){
				UiDevice.getInstance().pressKeyCode(c-68);
				}
					else
						if(c >=65&&c <=90){
				UiDevice.getInstance().pressKeyCode(59);
				sleep(20);
				UiDevice.getInstance().pressKeyCode(c-36);
				}
						else 
							if(c ==32){
				UiDevice.getInstance().pressKeyCode(62);
				}
							else{}
				}

 Keycode:

keycode 1 = 鼠标左键
keycode 2 = 鼠标右键
keycode 3 = Cancel
keycode 4 = 鼠标中键
keycode 8 = BackSpace 
keycode 9 = Tab 
keycode 12 = Clear(未知) 
keycode 13 = Enter 
keycode 16 = Shift_L 
keycode 17 = Control_L 
keycode 18 = Alt_L 
keycode 19 = Pause 
keycode 20 = Caps_Lock 
keycode 27 = Escape 
keycode 32 = space 
keycode 33 = Prior(PageUp键) 
keycode 34 = Next(PageDown键) 
keycode 35 = End 
keycode 36 = Home 
keycode 37 = Left 
keycode 38 = Up 
keycode 39 = Right 
keycode 40 = Down 
keycode 41 = Select(未知) 
keycode 42 = Print(PrintScreen键) 
keycode 43 = Execute(未知) 
keycode 45 = Insert 
keycode 46 = Delete 
keycode 47 = Help(未知) 
keycode 48 = 0 equal braceright
keycode 49 = 1 exclam onesuperior 
keycode 50 = 2 quotedbl twosuperior 
keycode 51 = 3 section threesuperior 
keycode 52 = 4 dollar 
keycode 53 = 5 percent 
keycode 54 = 6 ampersand 
keycode 55 = 7 slash braceleft 
keycode 56 = 8 parenleft bracketleft 
keycode 57 = 9 parenright bracketright 
keycode 65 = a A 
keycode 66 = b B 
keycode 67 = c C 
keycode 68 = d D 
keycode 69 = e E EuroSign 
keycode 70 = f F 
keycode 71 = g G 
keycode 72 = h H 
keycode 73 = i I 
keycode 74 = j J 
keycode 75 = k K 
keycode 76 = l L 
keycode 77 = m M mu 
keycode 78 = n N 
keycode 79 = o O 
keycode 80 = p P 
keycode 81 = q Q at 
keycode 82 = r R 
keycode 83 = s S 
keycode 84 = t T 
keycode 85 = u U 
keycode 86 = v V 
keycode 87 = w W 
keycode 88 = x X 
keycode 89 = y Y 
keycode 90 = z Z 
keycode 96 = KP_0 KP_0(小键盘数字0) 
keycode 97 = KP_1 KP_1(小键盘数字1) 
keycode 98 = KP_2 KP_2(小键盘数字2) 
keycode 99 = KP_3 KP_3(小键盘数字3) 
keycode 100 = KP_4 KP_4(小键盘数字4) 
keycode 101 = KP_5 KP_5(小键盘数字5) 
keycode 102 = KP_6 KP_6(小键盘数字6) 
keycode 103 = KP_7 KP_7(小键盘数字7) 
keycode 104 = KP_8 KP_8(小键盘数字8) 
keycode 105 = KP_9 KP_9(小键盘数字9) 
keycode 106 = KP_Multiply KP_Multiply(小键盘乘) 
keycode 107 = KP_Add KP_Add(小键盘加)
keycode 108 = KP_Separator KP_Separator(小键盘回车键)
keycode 109 = KP_Subtract KP_Subtract(小键盘减) 
keycode 110 = KP_Decimal KP_Decimal(小键盘小数点) 
keycode 111 = KP_Divide KP_Divide(小键盘除) 
keycode 112 = F1 
keycode 113 = F2 
keycode 114 = F3 
keycode 115 = F4 
keycode 116 = F5 
keycode 117 = F6 
keycode 118 = F7 
keycode 119 = F8 
keycode 120 = F9 
keycode 121 = F10 
keycode 122 = F11 
keycode 123 = F12 
keycode 124 = F13 
keycode 125 = F14 
keycode 126 = F15 
keycode 127 = F16 
keycode 128 = F17 
keycode 129 = F18 
keycode 130 = F19 
keycode 131 = F20 
keycode 132 = F21 
keycode 133 = F22 
keycode 134 = F23 
keycode 135 = F24 
keycode 136 = Num_Lock 
keycode 137 = Scroll_Lock(未知) 
keycode 187 = acute grave(未知) 
keycode 188 = comma semicolon(未知)(逗号 分号) 
keycode 189 = minus underscore (减号 下划线)
keycode 190 = period colon (未知 冒号)
keycode 192 = numbersign apostrophe(未知 单引号) 
keycode 210 = plusminus hyphen macron (未知 & ^)
keycode 211 = 
keycode 212 = copyright registered(未知) 
keycode 213 = guillemotleft guillemotright(未知) 
keycode 214 = masculine ordfeminine(未知) 
keycode 215 = ae AE(未知) 
keycode 216 = cent yen(未知) 
keycode 217 = questiondown exclamdown(未知) 
keycode 218 = onequarter onehalf threequarters(未知) 
keycode 220 = less greater bar(小于号 大于号 未知) 
keycode 221 = plus asterisk asciitilde(加号 星号 未知) 
keycode 227 = multiply division(乘 除)
keycode 228 = acircumflex Acircumflex(未知) 
keycode 229 = ecircumflex Ecircumflex(未知) 
keycode 230 = icircumflex Icircumflex(未知) 
keycode 231 = ocircumflex Ocircumflex(未知)
keycode 232 = ucircumflex Ucircumflex(未知) 
keycode 233 = ntilde Ntilde(未知) 
keycode 234 = yacute Yacute(未知) 
keycode 235 = oslash Ooblique(未知) 
keycode 236 = aring Aring(未知) 
keycode 237 = ccedilla Ccedilla(未知) 
keycode 238 = thorn THORN(未知) 
keycode 239 = eth ETH(未知) 
keycode 240 = diaeresis cedilla currency(未知) 
keycode 241 = agrave Agrave atilde Atilde(未知) 
keycode 242 = egrave Egrave(未知) 
keycode 243 = igrave Igrave(未知) 
keycode 244 = ograve Ograve otilde Otilde(未知) 
keycode 245 = ugrave Ugrave(未知) 
keycode 246 = adiaeresis Adiaeresis(未知) 
keycode 247 = ediaeresis Ediaeresis(未知) 
keycode 248 = idiaeresis Idiaeresis(未知) 
keycode 249 = odiaeresis Odiaeresis(未知) 
keycode 250 = udiaeresis Udiaeresis(未知) 
keycode 251 = ssharp question backslash(未知) 
keycode 252 = asciicircum degree(未知) 
keycode 253 = 3 sterling(未知) 
keycode 254 = Mode_switch(未知)

Ascii:

bubuko.com,布布扣

 

Android测试之Keycode

标签:android   blog   http   io   ar   os   使用   sp   java   

原文地址:http://www.cnblogs.com/udld/p/4120044.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!