gpt4 book ai didi

android - 使用 monkey runner 验证

转载 作者:行者123 更新时间:2023-11-29 00:41:43 24 4
gpt4 key购买 nike

考虑这个场景:

  1. 你有一个文本框,你必须在其中写一些文本“abcd”
  2. 接下来您必须验证输入的文本是否属于正确的字符集(如 UTF-8),或者您只需验证“abcd”是否已输入到文本框中

这是在一次采访中被问到的。我必须编写一个可以执行上述两个操作的 monkeyrunner 脚本。第一个太容易了。对第二个有什么意见吗?

最佳答案

使用 AndroidViewClient这个 monkeyrunner 脚本可以像

#! /usr/bin/env monkeyrunner

from com.dtmilano.android.viewclient import ViewClient
...

device = MonkeyRunner.waitForConnection()
s = "abcd"
device.type(s)
vc = ViewClient(device)
vc.dump()
editText = vc.findViewById("id/EditText") # if you don't know the id you can use vc.getViewIds()
if s == editText.mText():
print "OK"

关于android - 使用 monkey runner 验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8940743/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com