• uiautomator特殊场景


    1.自定义参数

    运行时指定-e:adb shell uiautomator runtest Demo.jar --no-hup -c com.demo.TestDemo -e phone 10086
    
    Bundle d=getParams();
    
    String phone=(String)b.get("phone");

    2.send key的方式清除

    UiDevice.getInstance().pressKeyCode(KeyEvent.KEYCODE_MOVE_END);
    
    UiDevice.getInstance().pressKeyCode(KeyEvent.KEYCODE_DEL);

    this.getUiDevice().pressKeyCode(1); 键盘按键

    3.Configurator(间隔) 功能

    1)可调节两个模拟动作之间的默认间隔  setActionAcknowledgmentTimeout(5);

    2)可调节输入文本的输入时间间隔   setKeyInjectionDelay(long delay)

    3)可调节每次滚动的时间间隔  setScrollAcknowledgmentTimeout(long timeout)

    4)可调节等待系统空闲的默认时间  setWaitForIdleTimeout(long timeout)

     Configurator.getInstance().setActionAcknowledgmentTimeout(5);
    
    sleep(2000);
    
    UiDevice.getInstance().swipe(x-50,y/2,50,y/2,10);
    
    UiDevice.getInstance().swipe(x-50,y/2,50,y/2,10);//在屏幕上滑动

     4.API:

    System.out.println( this.getUiDevice().isNaturalOrientation());  //是否竖屏

    this.getUiDevice().setOrientationLeft();
    System.out.println( this.getUiDevice().isNaturalOrientation());
    System.out.println( this.getUiDevice().getDisplayRotation());  //显示角度  
     
     
     
    5.滑动三种方式
              Point s=new Point();
              Point s1=new Point();
              Point[] t={s,s1};        
              this.swipe(t, 13);
     ShellUtil.exec("input swipe 500 1400 500 700 500");
     
    UiScrollable aa=new UiScrollable(new UiSelector().resourceId("com.android.browser:id/title"));
         aa.flingBackward();
         aa.flingForward();      
         aa.scrollToEnd(10);
         aa.scrollIntoView(uiobject);
     
     
    6.两指放大 
    new UiObject(new UiSelector().resourceId(sp.UrlAddress)).pinchOut(50, 20);

    performMultiPointGesture(PointerCoords.touches)

    7.模拟按键,事件注入
    http://www.cnblogs.com/by-dream/p/5195121.html
     
    press.sh
     
    #!/bin/sh
    sendevent /dev/input/event6 1 116 1
    sendevent /dev/input/event6 0 0 0
    echo "down"
    sendevent /dev/input/event6 1 116 1
    sendevent /dev/input/event6 0 0 0
    echo "down"
    sendevent /dev/input/event6 1 116 1
    sendevent /dev/input/event6 0 0 0
    echo "down"
    sendevent /dev/input/event6 1 116 1
    sendevent /dev/input/event6 0 0 0
    echo "down"
    sendevent /dev/input/event6 1 116 1
    sendevent /dev/input/event6 0 0 0
    echo "down"
    sendevent /dev/input/event6 1 116 1
    sendevent /dev/input/event6 0 0 0
    echo "down"
    sendevent /dev/input/event6 1 116 1
    sendevent /dev/input/event6 0 0 0
    echo "down"
    sendevent /dev/input/event6 1 116 1
    sendevent /dev/input/event6 0 0 0
    echo "down"
    sendevent /dev/input/event6 1 116 1
    sendevent /dev/input/event6 0 0 0
    echo "down"
    sendevent /dev/input/event6 1 116 1
    sendevent /dev/input/event6 0 0 0
    echo "down"
    sendevent /dev/input/event6 1 116 1
    sendevent /dev/input/event6 0 0 0
    echo "down"
    sendevent /dev/input/event6 1 116 0
    sendevent /dev/input/event6 0 0 0
    echo "up"
  • 相关阅读:
    redis info详解
    redis数据类型-有序集合
    redis数据类型-集合类型
    redis数据类型-列表类型
    python——井字小游戏
    python——元组和字典学习笔记
    docker学习笔记
    中型公司网络架构拓扑与详解
    python——将图片转换为字符编码(linux版的)
    python——冒泡排序练习
  • 原文地址:https://www.cnblogs.com/season-xie/p/5365713.html
Copyright © 2020-2023  润新知