robotium 获取控件ID方法
来源:互联网 发布:mysql delete in语句 编辑:程序博客网 时间:2024/06/06 08:40
直接放在测试工程里用,改下包名。
5s刷新一次,需要自行在logcat窗口中设置筛选条件tag=getCurrentInfo 然后就~自行发挥吧
public class GetInfoTest extends ActivityInstrumentationTestCase2 { private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "xxxxx.xxxxxxxx.xxxxxxxxxx.xxxxxxxxxx"; private static Class launcherActivityClass; static { try { launcherActivityClass = Class .forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } public GetInfoTest() throws ClassNotFoundException { super(launcherActivityClass); } private Solo solo; protected void setUp() throws Exception { solo = new Solo(getInstrumentation(), getActivity()); } public void tearDown() throws Exception { } public void testGetInfo(){ while(true){ solo.sleep(5000); getCurrentInfo(); } } public void getCurrentInfo(){ Log.v("getCurrentInfo", "current activity is " + solo.getCurrentActivity().getClass().getSimpleName()); ArrayList<View> av = solo.getCurrentViews(); Log.v("getCurrentInfo", "begin get view info"); for (View view : av) { Log.v("getCurrentInfo", "* * * * * * *"); int[] location = { 0, 0 }; view.getLocationInWindow(location); Log.v("getCurrentInfo", "location:" + location[0] + "," + location[1]); Log.v("getCurrentInfo", "name:" + view.getClass().getName()); int id = view.getId(); if (view instanceof TextView) { Log.v("getCurrentInfo", "text:" + ((TextView) view).getText().toString()); } if (view instanceof ViewGroup) { Log.v("getCurrentInfo", "this view is a viewgroup"); } if (id == -1) continue; if (null != view.getResources() && null != view.getResources().getResourceEntryName(id)) Log.v("getCurrentInfo", "id:"+view.getResources().getResourceEntryName(id) + ",resourse:" + Integer.toHexString(id)); Log.v("getCurrentInfo", "clickable:"+view.isClickable()); Log.v("getCurrentInfo", "Enable:"+view.isEnabled()); } ArrayList<WebElement> WebElementsList = solo.getCurrentWebElements(); Log.v("getCurrentInfo", "begin get webelements"); for (WebElement we : WebElementsList) { Log.v("getCurrentInfo", "classname is " + we.getClassName()); Log.v("getCurrentInfo", "id is " + we.getId()); Log.v("getCurrentInfo", "x is " + we.getLocationX()); Log.v("getCurrentInfo", "y is " + we.getLocationY()); Log.v("getCurrentInfo", "name is " + we.getName()); Log.v("getCurrentInfo", "tag name is " + we.getTagName()); Log.v("getCurrentInfo", "text is " + we.getText()); } }}
0 0
- robotium 获取控件ID方法
- robotium 黑盒 获取id点击控件
- android robotium获取相同id的的控件
- android robotium获取相同id的的控件
- android robotium获取相同id的的控件
- android robotium获取相同id的的控件
- JQuery获取服务端控件ID的方法
- robotium 中获取相同类型的自控觉得获取方法(使用Android的ViewGroup控件的getChildAt(index)获取)
- 雾山的Robotium学习笔记---通过Id寻找控件
- 雾山的Robotium学习笔记---通过Id寻找控件 .
- 已知控件的id,在Robotium中如何模拟按键
- JS获取控件ID
- JS获取控件ID
- 根据控件ID获取控件
- 分享一个获取控件 id 较简单的方法
- robotium获取所有控件GridView、ScrollView下所有控件
- 获取ID方法探讨
- 获取ID方法探讨
- 启动resin时由于jdk是1.8版本报错:JDWP Transport dt_socket failed to initialize, TRANSPORT_LOAD
- zoj 1042 W's Cipher
- QT C++直接调用QML中的函数, 直接设置属性
- iOS 虚拟键盘添加view
- 上传应用程序到App Store 的具体操作流程
- robotium 获取控件ID方法
- Shell脚本之crontab定时任务
- 面向对象基础 (java4 Android 12,13,14,15集)
- zoj 1067 Color Me Less
- Linux 性能监测工具
- bgdmdgbgdmdg240090bgdmdg
- 使用sysbench进行cpu/IO/内存/OLTP等基准测试
- 一点KeepAlive的知识
- linux so库生成(一)