1

我正在使用calabash-android为android应用程序编写一系列自动化测试,我需要能够检测android系统键盘是否可见并且(如果可能)读取一些键(即如果返回键说Done而不是NextEnter)。我知道有keyboard_visible?适用于 iOS 的命令,但我无法找到适用于 android 的任何类似命令。

有没有人构建自己的函数来处理这些实例?

4

2 回答 2

1

there is a way to take a dump of the screens current contents on android using a tool called uiautomator from the android SDK. You can then check this for whatever you need to. It's not the most elegant solution but it might just work. Have a look at this post.

Calabash handling "Complete action using" dialog

于 2015-01-16T10:57:16.053 回答
0
windown_input_method = %x(adb -s #{ENV['ADB_DEVICE_ARG']} shell dumpsys window InputMethod | grep "mHasSurface")
windown_input_method.include?("isReadyForDisplay()=true")

如果键盘可见,则返回 true,如果不可见则返回 false ENV['ADB_DEVICE_ARG'] 是环境变量,保存您连接的 android 设备的设备 ID。如果您总是在一台设备上运行,只需

windown_input_method = %x(adb shell dumpsys window InputMethod | grep "mHasSurface")
windown_input_method.include?("isReadyForDisplay()=true")

会做

于 2017-01-30T11:40:43.510 回答