1

I'm writing a test to detect if the predictions portion of the android keyboard is disabled or not. Usually to detect these sorts of things, I would take an XML screenshot in UI Automator and then use the resource ID to detect it, but since the keyboard is recorded as an overlay, it doesn't show up.

I've used the resource ID to create strings and instantiate them like this:

UiObject incidentClick = uiDevice.findObject(new 
UiSelector().resourceId(UIResourceStrings.This_Is_The_Resource_String));

However, that doesn't work since the keyboard does not have its own resource string.

I've thought about using (x,y) coordinates to check, but I'm not sure how I would implement that. Any idea on how to do something like this?

TriskalJM
  • 2,393
  • 1
  • 19
  • 20
Johncarlo
  • 15
  • 6

2 Answers2

0

Not a complete solution, but instead a workaround. I got the value for the text first, then had a click(x,y) function click on the space where one of the suggestions appeared, then got the value for the text first and checked them to see if they were the same. If they weren't, then the keyboard predictor was enabled and the test would fail.

Just a note, the predictor should give a different word than the original. So a Ui Object will be created if your text == uiDevice.findObject(new UiSelector().text("text"));

Johncarlo
  • 15
  • 6
0

If you use UiAutomator 2.0, you can execute an adb shell command in your case and get the Keypad status, it's easy like this,

"adb dumpsys input_method |grep mInputShow"

when the value of mInputShow is true, the keypad is opened.

Ryan_D
  • 11
  • 1