使用 Monkey runner 进行验证

发布于 2024-12-27 19:37:18 字数 196 浏览 5 评论 0原文

考虑这种情况:

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

这是在采访中向我询问的。我必须编写一个 Monkeyrunner 脚本来执行上述两个操作。第一个非常简单。对2号有意见吗?

Consider this scenario:

  1. You have a textbox in which you have to write some text "abcd"
  2. Next you have to verify if the entered text belongs to the correct character set (like UTF - 8) or simply you have to verify that "abcd" has been entered into the text box

This was asked to me in an interview.I had to write a monkeyrunner script that could do the above mentioned two operations. 1st one was damn easy. Any comments on the 2nd one?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情绪操控生活 2025-01-03 19:37:18

使用 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"

Using AndroidViewClient this monkeyrunner script could be as simpler as

#! /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"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文