uiautomator案例

test下新建类

复制代码
public class ButtonClickTest {
    private UiDevice device;

    @Before
    public void setUp() {
        // 初始化 UiDevice 实例
        device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
        try {
            device.executeShellCommand("am start -n com.yy.test/.MainActivity"); //启动,包名,Activity名
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testButtonClick() throws UiObjectNotFoundException {

        UiObject user = device.findObject(new UiSelector().resourceId("com.yy.test:id/user"));
        user.clearTextField();
        user.setText("admin");

        UiObject pass = device.findObject(new UiSelector().resourceId("com.yy.test:id/pass"));
        pass.clearTextField();
        pass.setText("123456");

        UiObject button = device.findObject(new UiSelector().resourceId("com.yy.test:id/btnLogin"));
        button.click();

    }
}
相关推荐
WordPress学习笔记6 分钟前
wordpress根据页面别名获取该页面的链接
android·wordpress
2501_9160074723 分钟前
iOS 崩溃日志的分析方法,将崩溃日志与运行过程结合分析
android·ios·小程序·https·uni-app·iphone·webview
浅箬1 小时前
Taro3的H5项目在Android、IOS 中因为兼容性问题导致的白屏问题
android·团队开发·taro
技术摆渡人1 小时前
Android 全栈架构终极指南:从 Linux 内核、Binder 驱动到 Framework 源码实战
android·linux·架构
00后程序员张1 小时前
苹果应用商店上架App流程,签名证书、IPA 校验、上传
android·ios·小程序·https·uni-app·iphone·webview
2501_916007471 小时前
iOS 上架需要哪些准备,围绕证书、描述文件和上传方式等关键环节展开分析
android·ios·小程序·https·uni-app·iphone·webview
QING6181 小时前
Kotlin Flow 的 emit 和 tryEmit 有什么区别 ?
android·kotlin·android jetpack
2501_915106322 小时前
iOS 上架费用解析,哪些成本可以通过流程优化降低。
android·ios·小程序·https·uni-app·iphone·webview
顾林海2 小时前
Android暗黑模式适配全攻略:从入门到精通,告别"阴间配色"
android·面试·性能优化
唔662 小时前
出厂前一次性授权
android