Uiautomator 2.0之Configrator类学习小记
1. Configration类介绍
1.1. Configrator用于设置脚本动作的默认延时
1.2 Configrator功能:
1.2.1 可调节两个模拟动作之间的默认间隔
1.2.2 可调节输入文本的输入时间间隔
1.2.3 可调节每次滚动的时间间隔
1.2.4 可调节等待系统空闲的默认时间
2. 相关API介绍
延时项 | 默认延时 | 说明 | API |
动作 | 3s | 设置延时 | setActionAcknowledgmentTimeout(long timeout) |
获取默认延时 | getActionAcknowledgmentTimeout() | ||
键盘输入 | 0s | 设置延时 | setKeyInjectionDelay(long delay) |
获取默认延时 | getKeyInjectionDelay() | ||
滚动 | 200ms | 设置延时 | setScrollAcknowledgmentTimeout(long timeout) |
获取默认延时 | getScrollAcknowledgmentTimeout() | ||
空闲 | 10s | 设置延时 | setWaitForIdleTimeout(long timeout) |
获取默认延时 | getWaitForIdleTimeout() | ||
组件查找 | 10s | 设置延时 | setWaitForSelectorTimeout(long timeout) |
获取默认延时 | getWaitForSelectorTimeout() |
3. 代码示例
1 @Test 2 public void testCase08(){ 3 4 Configurator configurator = Configurator.getInstance(); 5 long defaultActionDelay = configurator.getActionAcknowledgmentTimeout(); 6 long defaultKeyInjectDelay = configurator.getKeyInjectionDelay(); 7 long defaultScrollDelay = configurator.getScrollAcknowledgmentTimeout(); 8 long defaultWaitDelay = configurator.getWaitForIdleTimeout(); 9 long defalutWaitSelector = configurator.getWaitForSelectorTimeout(); 10 11 12 configurator.setActionAcknowledgmentTimeout(1000); 13 configurator.setKeyInjectionDelay(1500); 14 configurator.setScrollAcknowledgmentTimeout(2000); 15 configurator.setWaitForIdleTimeout(2500); 16 configurator.setWaitForSelectorTimeout(3000); 17 18 long updatedActionDelay = configurator.getActionAcknowledgmentTimeout(); 19 long updatedKeyInjectDelay = configurator.getKeyInjectionDelay(); 20 long updatedScrollDelay = configurator.getScrollAcknowledgmentTimeout(); 21 long updatedWaitDelay = configurator.getWaitForIdleTimeout(); 22 long updatedWaitSelector = configurator.getWaitForSelectorTimeout(); 23 24 25 Log.i("testConfigrator", "defaultActionDelay: "+defaultActionDelay); 26 Log.i("testConfigrator", "updatedActionDelay: "+updatedActionDelay); 27 28 Log.i("testConfigrator", "defaultKeyInjectDelay: "+defaultKeyInjectDelay); 29 Log.i("testConfigrator", "updatedKeyInjectDelay: "+updatedKeyInjectDelay); 30 31 Log.i("testConfigrator", "defaultScrollDelay: "+defaultScrollDelay); 32 Log.i("testConfigrator", "updatedScrollDelay: "+updatedScrollDelay); 33 34 Log.i("testConfigrator", "defaultWaitDelay: "+defaultWaitDelay); 35 Log.i("testConfigrator", "updatedWaitDelay: "+updatedWaitDelay); 36 37 Log.i("testConfigrator", "defalutWaitSelector: "+defalutWaitSelector); 38 Log.i("testConfigrator", "updatedWaitSelector: "+updatedWaitSelector); 39 40 }
运行结果:
原创:http://blog.csdn.net/swordgirl2011/article/details/51002494