1.å¦ä½ä½¿ç¨monkeyrunnerä¸viewè¿è¡äº¤äº
å¦ä½ä½¿ç¨monkeyrunnerä¸viewè¿è¡äº¤äº
å¦ä½ä½¿ç¨monkeyrunnerä¸viewè¿è¡äº¤äº
androidå®æ¹éçmonkeyrunneråªä»ç»äºä¸äºæéçuiæµè¯æ¹æ³. æ¯å¦åªè½æå®åæ ç¹æ¨¡ææä½è¡ä¸º,源码游戏盒子源码 c æµè¯ç»æ对æ¯åªè½éè¿æªå¾è¿è¡ç®å对æ¯ç»æ. å½ç¶æ们å¯ä»¥èªæçæ¥å®ç°çæµå°viewè§å¾çåæ ç¹,é£ä¹æ们就å¯ä»¥årobotiumä¸æ ·, å¨monkeyrunnerèæ¬ä¸,对æ§ä»¶çº§çviewè§å¾è¿è¡äº¤äºæä½.
å¦ä½å®ç°ææå°å½åactivityå±ç°çææçæ§ä»¶**å¢ï¼monkeyrunner.jar éç®åæEasyMonkeyDevice.class å By.class ï¼ æä¾äºä¸äºæ°çapi, å¾å¤§ç满足äºä¸äºé«çº§éæ±ï¼
æå 个blogæç« å¯¹EasyMonkeyDeviceç±»çapiè¿è¡äºä¸äºç¤ºä¾ï¼ éå¸¸æµ æ¾ææï¼
yançå客 Android æµè¯ä¹åè¯ Monkeyrunnerã å½å¤ç diegoä¹åäºä¸ç³»åå ³äºmonkeyrunner çæç« ï¼å¹¶èªå·±åäºä¸äºviewclient apis å¯ä»¥ä¸è½½å° ï¼é常ä¸éï¼è¯·å¤§å®¶åèï¼ä½æ¯diego æå客åéäºblogspotä¸ï¼ åï¼æ以大éçæå们就éé·äºï¼åªè½**çäºï¼
å ¶å®ä»¥ä¸æææç« ä¸»è¦éè¿ä½¿ç¨äºBy , EasyMonkeyDevice , monkeydevice è¿3个类æ¥å®ç°ä¸view objectç交äºï¼ é£æ们就对è¿3个类è¿è¡ç®åçåæä¸ä¸ï¼
访é®è¿é å¯ä»¥çå°EasyMonkeyDeviceåByçæºç ï¼**æµè§ï¼ï¼
1. By.class å¯ä»¥æ ¹æ®idè·å¾viewobject ï¼ ä¾å¦æ们æä¸ä¸ªtext view çidæ¯ id/account é£ä¹æ们就å¯ä»¥éè¿å¦ä¸è·å¾è¯¥view object. account = By.id(âid/accountâ)
2. EasyMonkeyDevice.classè·å¾view objectåï¼å¯ä»¥ç¨EasyMonkeyDeviceç±»è¿è¡ä¸äºæä½ï¼ getText() , touch(), type(). åå«ä¸ºè·å¾è¯¥view object çææ¬å¼ï¼ è¿è¡è§¦æ¸å±æä½ï¼å ¶ä¼è·åview objectçåæ å¼ï¼å¹¶è¿è¡æä½ï¼. type() åä¼å touch, ç¶åè¾å ¥åç¬¦ï¼ 3. monkeyDevice **æµè§æºç
# éè¿MonkeyDeviceè·åHierarchyViewer对象å®ä¾ hierarchy_viewer = device.getHierarchyViewer()
#éè¿HierarchyViewerè·åViewNodeå®ä¾ï¼ä¸ä¸ªviewnodeå®ä¾ä»£è¡¨ä¸ä¸ªæ§ä»¶ï¼ view_node = hierarchy_viewer.findView(By.id(âid/emptyTextâ))
#è·åæ§ä»¶å çææ¬
text = view_node.namedProperties.get(âmTextâ).toString() if text.find(âh**e anyâ) < 0: print ânot find h**e any!â else:
print âfind h**e any!â print text
æ»ç»ï¼ å¦æ¤è¿è¬ï¼æ们ç¨monkeyrunner ä¹å¯ä»¥ååºårobotiumä¸æ ·çèæ¬ï¼å¯ä»¥å¯¹view object è¿è¡æä½ï¼ èä¸å¯ä»¥ååæ ç¹å¼çæ¹æ³è¿è¡èåï¼ å¯ä»¥ç±å¾å¤§ççªç ´ï¼