Sometimes your View will not have a ResourceId , for example, when you need to programmatically enter a text box inside a web page made inside a WebView . i.e.
In such cases, we need to use the UiSelector class to dynamically search for EditText ; however, you will find that the returned Matcher<View> not compatible with the onView(with(...)) methods.
When using UiSelector you can use the UiDevice link for software fake keystrokes using the approach below:
private static final KeyCharacterMap MAP_KEYCODE = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD); private final void type(final UiObject pUiObject, final String pString, final boolean pIsSimulateTyping, final boolean pIsClearField) throws Exception {
Alex T.
source share