丹阳网站建设如何,微信搜索推广,老牌网站建设,德州手机网站建设服务点击控件的具体位置 d(textSettings).click(offset(0.5, 0.5)) 点击控件的中间位置 d(textSettings).click(offset(0, 0)) 点击控件的左上方 d(textSettings).click(offset(1, 1)) 点击控件的右下方 拖动控件 d(textSettingsSettings).click(offset(0.5, 0.5)) 点击控件的中间位置 d(textSettings).click(offset(0, 0)) 点击控件的左上方 d(textSettings).click(offset(1, 1)) 点击控件的右下方 拖动控件 d(textSettings).swipe(right) d(textSettings).swipe(left, steps10) d(textSettings).swipe(up, steps20) d(textSettings).swipe(down, steps20) # 1 steps is about 5ms, so 20 steps is about 0.1s 特定UI对象上的两点手势从边缘到中心向外从中心到边缘
# 从边缘到中心
d(textSettings).pinch_in(percent100, steps10) # 从中心到边缘 d(textSettings).pinch_out()等待特定的界面出现或者消失 # 等待UI出现
d(textSettings).wait(timeout3.0) # return bool # 等待UI消失 d(textSettings).wait_gone(timeout1.0)对特定的UI对象执行Fling可滚动默认时间20s # 向前默认
d(scrollableTrue).fling()
# 掷球前水平 d(scrollableTrue).fling.horiz.forward() # 垂直向后投掷 d(scrollableTrue).fling.vert.backward() # 水平开始 d(scrollableTrue).fling.horiz.toBeginning(max_swipes1000) # 垂直抛向末端 d(scrollableTrue).fling.toEnd()对特定的UI对象执行滚动 水平或垂直 向前或向后或开始或结束 # 垂直向前滚动默认
d(scrollableTrue).scroll(steps10) # 水平向前滚动 d(scrollableTrue).scroll.horiz.forward(steps100) # 垂直向后滚动 d(scrollableTrue).scroll.vert.backward() # 水平 d(scrollableTrue).scroll.horiz.toBeginning(steps100, max_swipes1000) # 垂直滚动到结尾 d(scrollableTrue).scroll.toEnd() # 垂直向前滚动直到出现特定的UI对象d(scrollableTrue).scroll.to(textSecurity)当选择器找不到匹配项时uiautomator2将运行所有注册的观察程序条件匹配时单击目标 d.watcher(AUTO_FC_WHEN_ANR).when(textANR).when(textWait) \ .click(textForce Close)#使用不带参数的click d.watcher(ALERT).when(textOK).click()#same as d.watcher(ALERT).when(textOK).click(textOK)#当条件为真时按键 d.watcher(AUTO_FC_WHEN_ANR).when(textANR).when(textWait) \ .press(back, home)#检查指定的观察程序是否触发一个观察者被触发这意味着观察者已经运行并且其所有条件都匹配。 # true in case of the specified watcher triggered, else false d.watcher(watcher_name).triggered
#展示所有watch d.watchers#通常可以用来自动点击权限确认框或者自动安装 d.watcher(OK).when(textOK).click(textOK) # enable auto trigger watchers d.watchers.watched True # disable auto trigger watchers d.watchers.watched False # get current trigger watchers status assert d.watchers.watched False#移除watch # remove all registered watchers
d.watchers.remove()
# remove the named watcher, same as d.watcher(watcher_name).remove()
d.watchers.remove(watcher_name)全局设置#用户每次点击后延迟1.5s d.click_post_delay 1.5#设置默认元素超时时间s d.wait_timeout 30.0 #输入法 d.set_fastinput_ime(True) # 切换成FastInputIME输入法
d.send_keys(你好123abcEFG) # adb广播输入 d.clear_text() # 清除输入框所有内容(Require android-uiautomator.apk version 1.0.7) d.set_fastinput_ime(False) # 切换成正常的输入法 d.send_action(search) # 模拟输入法的搜索 uiautomation2哈哈哈哈 转载于:https://www.cnblogs.com/zhujunsheng/p/10452073.html