NAF Nodes, Automation with Robotium

半城伤御伤魂 提交于 2019-12-11 04:54:55

问题


I'm having a problem in accessing some components on my UI using Robotium. I discovered there are some nodes (NAF nodes) that are not accesible from automated tool as Robotium.

Is there a way to access them? I would not use click using specific coordinates.

Could you suggest me the best practices for problems like this?

This is the image of layout seen from UI Automator.


回答1:


If you want to access the elements of a particular list view the following code should help you achieve that:

ListView lv = (ListView) solo.getView(id); //id is R.id.(list view id).
if (lv.getChildCount() > 0) {
    for (int i = 0; i < lv.getAdapter().getCount(); i++) {
    // Code to access each row of the list view. In my case each row is a linear layout and       has a text view.
        LinearLayout linearLayout = (LinearLayout) Utils.getViewAtIndex(lv, i,
                    getInstrumentation());
        TextView accountName = (TextView) linearLayout.findViewById(R.id.(TextView id));
    }
}


来源:https://stackoverflow.com/questions/20358149/naf-nodes-automation-with-robotium

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!