2

我正在使用 android 版本 4.4.2 和 python 2.7 进行 UI 自动化。

当我尝试使用 UI automator/culebra/dump 捕获视图时,我无法捕获 QWERTY 键盘视图。请帮助我

我需要在 qwerty 键盘上触摸和输入,我应该能够输入字母数字文本和笑脸。同样,一旦输入,您应该验证屏幕上显示的内容是否是您要输入的内容。

提前致谢。

4

4 回答 4

0

正如另一个答案所提到的,使用UiAutomator后端的AndroidViewClient无法转储主窗口以外的任何内容,因此无法访问输入法窗口。

AndroidViewClient支持其他后端,例如ViewServer。您可以查看AndroidViewClient源代码提供的示例,特别是在dump-all-windows.py中,它显示了如何转储其他窗口的内容,而不仅仅是主窗口。即使您可以在键盘中获得大部分视图,但实际的键是由内部处理的com.android.inputmethod.keyboard.internal.PreviewPlacerView,因此您将无法单独与它们进行交互。

请记住,您始终可以使用它们的坐标来触摸键,例如

  if device.isKeyboardShown():
    device.touch(400, 950)

这将触及768x1280 模拟器上的G。但这取决于设备。

于 2014-09-23T17:58:43.090 回答
0

QWERTY 键盘是 webview,UiAutomator 目前不支持 webview。AndroidViewClient 基于 UiAutomator,因此不会捕获键盘。

如果您的目标只是键入文本,您可以先检测焦点是否在文本字段上,然后使用device.type('your_text').

于 2014-09-22T06:12:21.393 回答
0

如果您打算按键盘上的字符,请使用:

getDevice().pressKeyCode(KeyEvent.<KeyCode>)

KeyCode 可以从: http: //developer.android.com/reference/android/view/KeyEvent.html获得, 但在此之前,您需要将字符串转换为字符并传递每个字符以获取 KeyEventCode。

于 2014-12-05T11:35:18.400 回答
0
can perform:
typeInDevice("Any text")
or
typeInView("ViewId/content/text where you want to enter text","Any text")

device accessibility can be as your requirement .. 
self.typeInDevice()
or 
vc.typeInDevice()

Verification :
isKeyboardShown(): can be used for verifying that the keyboard 
is appeared.
the entered text can be retrieved by using gettext() and same can be 
compared with the entered value.
于 2016-04-15T08:22:48.303 回答