zoukankan      html  css  js  c++  java
  • Android无线测试之—UiAutomator UiSelector API介绍之一

    一、 UiSelector类介绍:

    1) UiSelector类说明:

      UiSelector代表一种搜索条件,可以在当前界面上查询和获取特定元素的句柄,当找到多余一个的匹配元素,则返回布局层次结构上第一个匹配元素作为目标UiObject,当构造一个UiSelector对象时,可以使用链式调用多个属性来缩小查询范围

    2)UiSelector功能:

      通过各种属性与节点关系定位组件

    3)自动化操作基本步骤:

      找到对象 —> 操作对象

      依据UiSelector找到对象,然后才可以操作对象

    二、程序例子:

    package com.testuiselector;
    
    import com.android.uiautomator.core.UiObject;
    import com.android.uiautomator.core.UiObjectNotFoundException;
    import com.android.uiautomator.core.UiSelector;
    import com.android.uiautomator.testrunner.UiAutomatorTestCase;
    
    public class Demo extends UiAutomatorTestCase {
    
        /**
         * @param args
         */
        public static void main(String[] args) {
            
            String jarName, testClass, testName, androidId;
            jarName="demo";
            testClass="com.testuiselector.Demo";
            testName="testDemo";
            androidId="1";
            new UiAutomatorHelper(jarName, testClass, testName, androidId);
    
        }
        
        public void testDemo() throws UiObjectNotFoundException{
            
            UiSelector l=new UiSelector().text("People");
            UiObject p=new UiObject(l);
            p.click();
            
        }
    
    }
    Demo.java
  • 相关阅读:
    磁盘冗余 ---RAID磁盘管理
    linux磁盘管理
    linux基础命令
    Apache配置rewrite
    memcache运维整理
    mysql主从配置
    rsync相关整理
    Lua 学习笔记(六)
    Lua 学习笔记(五)
    Lua 学习笔记(四)
  • 原文地址:https://www.cnblogs.com/fsw-blog/p/4552356.html
Copyright © 2011-2022 走看看