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

    四种匹配关系介绍

    一、四种匹配关系介绍:

    二、举例:

    匹配字符串   0123456789

    1、完全匹配: 0123456789

    2、包含匹配: 45678、456、678

    3、正则匹配: d{10}

    4、起始匹配: 012、01234、01234567

    三、程序举例:

    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 Demo1 extends UiAutomatorTestCase {
    
        /**
         * @param args
         */
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            String jarName, testClass, testName, androidId;
            jarName="demo1";
            testClass="com.testuiselector.Demo1";
            testName="testMatch";
            androidId="1";
            new UiAutomatorHelper(jarName, testClass, testName, androidId);
        }
            
        public void testSelector() throws UiObjectNotFoundException{
            //UiSelector l=new UiSelector().text("People"); //完全匹配
            //UiSelector l=new UiSelector().textContains("ople");
            //UiSelector l=new UiSelector().textMatches(".*opl.*");
            UiSelector l=new UiSelector().textStartsWith("peo");
            UiObject people=new UiObject(l);
            people.click();
        }
    
    }
    Demo1.java
  • 相关阅读:
    Idea打包问题
    centos问题总结
    Linux CentOS7 系统目录详解
    centos下修改文件后如何保存退出
    利用windows上的VMware安装CentOS7
    VMware安装系统出现Operating System not found 解决方案
    mybatis 0 变成null问题
    Shiro权限前端调用302重定向
    java版本
    产品画原型工具放入到托管平台
  • 原文地址:https://www.cnblogs.com/fsw-blog/p/4556179.html
Copyright © 2011-2022 走看看