Appium 1.8.1/Java Client/UiAutomator2 sendKeys() not doing the correct thing


#1

It appears that sendKeys() (With UiAutomator2 and Java Client 6.1.0) on an element is clearing the element (setValue used to be able to be used, but it seems like that’s the incorrect option as well). I have a loop that’s trying to send 4 keys at a time to an element:

for (String characters : characterGroups) {
   element.sendKeys(characters);
}

The calls to the appium server are coming through as:

2018-07-09 14:45:07:785 - [HTTP] --> POST /wd/hub/session/4b7b9e83-52b7-42ab-b383-8b7698a13daa/element/587aec05-654e-42cd-b246-1fe648f17aed/value
2018-07-09 14:45:07:785 - [HTTP] {"id":"587aec05-654e-42cd-b246-1fe648f17aed","value":["BadF"]}
2018-07-09 14:45:07:786 - [debug] [W3C] Calling AppiumDriver.setValue() with args: [["BadF"],"587aec05-654e-42cd-b246-1fe648f17aed","4b7b9e83-52b7-42ab-b383-8b7698a13daa"]
2018-07-09 14:45:07:787 - [debug] [JSONWP Proxy] Proxying [POST /element/587aec05-654e-42cd-b246-1fe648f17aed/value] to [POST http://localhost:7555/wd/hub/session/c037a9b3-fb84-480f-8055-ffff8f37a459/element/587aec05-654e-42cd-b246-1fe648f17aed/value] with body: {"elementId":"587aec05-654e-42cd-b246-1fe648f17aed","text":"BadF","replace":false,"unicodeKeyboard":true}
2018-07-09 14:45:08:556 - [debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"c037a9b3-fb84-480f-8055-ffff8f37a459","status":0,"value":""}
2018-07-09 14:45:08:556 - [debug] [MJSONWP] Responding to client with driver.setValue() result: ""
2018-07-09 14:45:08:557 - [HTTP] <-- POST /wd/hub/session/4b7b9e83-52b7-42ab-b383-8b7698a13daa/element/587aec05-654e-42cd-b246-1fe648f17aed/value 200 772 ms - 74
2018-07-09 14:45:09:739 - [HTTP] --> POST /wd/hub/session/4b7b9e83-52b7-42ab-b383-8b7698a13daa/element/587aec05-654e-42cd-b246-1fe648f17aed/value
2018-07-09 14:45:09:739 - [HTTP] {"id":"587aec05-654e-42cd-b246-1fe648f17aed","value":["ind,"]}
2018-07-09 14:45:09:740 - [debug] [W3C] Calling AppiumDriver.setValue() with args: [["ind,"],"587aec05-654e-42cd-b246-1fe648f17aed","4b7b9e83-52b7-42ab-b383-8b7698a13daa"]
2018-07-09 14:45:09:741 - [debug] [JSONWP Proxy] Proxying [POST /element/587aec05-654e-42cd-b246-1fe648f17aed/value] to [POST http://localhost:7555/wd/hub/session/c037a9b3-fb84-480f-8055-ffff8f37a459/element/587aec05-654e-42cd-b246-1fe648f17aed/value] with body: {"elementId":"587aec05-654e-42cd-b246-1fe648f17aed","text":"ind,","replace":false,"unicodeKeyboard":true}
2018-07-09 14:45:10:641 - [debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"c037a9b3-fb84-480f-8055-ffff8f37a459","status":0,"value":""}
2018-07-09 14:45:10:642 - [debug] [MJSONWP] Responding to client with driver.setValue() result: ""
2018-07-09 14:45:10:642 - [HTTP] <-- POST /wd/hub/session/4b7b9e83-52b7-42ab-b383-8b7698a13daa/element/587aec05-654e-42cd-b246-1fe648f17aed/value 200 903 ms - 74

However, the entry seems to get the “BadF”, then clear the field, then “ind,”

Please let me know if I’m using the right call (sendKeys()) or if I should use something else, or if it’s an issue that should be opened in Java Client, Appium Server, or UiAutomator2.


#2

Just for more information, it looks like “keys” is doing it as well (using the Actions class – as a side note, the actions.moveto and actions.click are failing with a 404):

    Actions actions = new Actions(driver);
    actions.moveToElement(element);
    actions.pause(Duration.ofMillis(100));
    actions.click();
    actions.pause(Duration.ofMillis(100));
    for (String key : value.split("")) {
        actions.sendKeys(key);
        actions.pause(Duration.ofMillis(20));
    }
    actions.build().perform();

The appium log shows “keys” being sent one at a time, but I’m seeing one character in the input, then clearing, then another etc…

2018-07-09 15:17:38:752 - [HTTP] --> POST /wd/hub/session/e4e92857-219e-4ea3-8ff3-018950f532cd/moveto
2018-07-09 15:17:38:752 - [HTTP] {"element":"eccd4d72-47b3-4ed4-9519-36624411fcb8"}
2018-07-09 15:17:38:752 - [W3C] Driver proxy active, passing request on via HTTP proxy
2018-07-09 15:17:38:754 - [debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/e4e92857-219e-4ea3-8ff3-018950f532cd/moveto] to [POST http://localhost:7085/wd/hub/session/26781bfe-6a42-46ec-aced-8d13e16a3e91/moveto] with body
: {"element":"eccd4d72-47b3-4ed4-9519-36624411fcb8"}
2018-07-09 15:17:38:807 - [W3C] Encountered internal error running command: Error: Could not proxy. Proxy error: Could not proxy command to remote server. Original error: 404 - undefined
2018-07-09 15:17:38:807 - [W3C]     at doJwpProxy$ (/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:456:13)
2018-07-09 15:17:38:807 - [W3C]     at tryCatch (/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
2018-07-09 15:17:38:807 - [W3C]     at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
2018-07-09 15:17:38:808 - [W3C]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
2018-07-09 15:17:38:808 - [W3C]     at GeneratorFunctionPrototype.invoke (/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
2018-07-09 15:17:38:808 - [W3C]     at <anonymous>
2018-07-09 15:17:38:822 - [HTTP] <-- POST /wd/hub/session/e4e92857-219e-4ea3-8ff3-018950f532cd/moveto 500 70 ms - 1423
2018-07-09 15:17:38:822 - [HTTP] 
2018-07-09 15:17:38:935 - [HTTP] --> POST /wd/hub/session/e4e92857-219e-4ea3-8ff3-018950f532cd/click
2018-07-09 15:17:38:936 - [HTTP] {"button":0}
2018-07-09 15:17:38:936 - [W3C] Driver proxy active, passing request on via HTTP proxy
2018-07-09 15:17:38:936 - [debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/e4e92857-219e-4ea3-8ff3-018950f532cd/click] to [POST http://localhost:7085/wd/hub/session/26781bfe-6a42-46ec-aced-8d13e16a3e91/click] with body: 
{"button":0}
2018-07-09 15:17:38:960 - [W3C] Encountered internal error running command: Error: Could not proxy. Proxy error: Could not proxy command to remote server. Original error: 404 - undefined
2018-07-09 15:17:38:960 - [W3C]     at doJwpProxy$ (/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:456:13)
2018-07-09 15:17:38:960 - [W3C]     at tryCatch (/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
2018-07-09 15:17:38:960 - [W3C]     at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
2018-07-09 15:17:38:960 - [W3C]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
2018-07-09 15:17:38:960 - [W3C]     at GeneratorFunctionPrototype.invoke (/Users/bedouglas/build_tools/scripts/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
2018-07-09 15:17:38:961 - [W3C]     at <anonymous>
2018-07-09 15:17:38:962 - [HTTP] <-- POST /wd/hub/session/e4e92857-219e-4ea3-8ff3-018950f532cd/click 500 26 ms - 1423
2018-07-09 15:17:38:962 - [HTTP] 
2018-07-09 15:17:39:072 - [HTTP] --> POST /wd/hub/session/e4e92857-219e-4ea3-8ff3-018950f532cd/keys
2018-07-09 15:17:39:072 - [HTTP] {"value":["B"]}
2018-07-09 15:17:39:072 - [debug] [W3C] Calling AppiumDriver.keys() with args: [["B"],"e4e92857-219e-4ea3-8ff3-018950f532cd"]
2018-07-09 15:17:39:073 - [debug] [JSONWP Proxy] Proxying [POST /keys] to [POST http://localhost:7085/wd/hub/session/26781bfe-6a42-46ec-aced-8d13e16a3e91/keys] with body: {"text":"B","replace":false,"unicodeKeyboard":true}
2018-07-09 15:17:39:739 - [debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"26781bfe-6a42-46ec-aced-8d13e16a3e91","status":0,"value":""}
2018-07-09 15:17:39:739 - [debug] [MJSONWP] Responding to client with driver.keys() result: null
2018-07-09 15:17:39:740 - [HTTP] <-- POST /wd/hub/session/e4e92857-219e-4ea3-8ff3-018950f532cd/keys 200 668 ms - 76
2018-07-09 15:17:39:740 - [HTTP] 
2018-07-09 15:17:39:770 - [HTTP] --> POST /wd/hub/session/e4e92857-219e-4ea3-8ff3-018950f532cd/keys
2018-07-09 15:17:39:771 - [HTTP] {"value":["a"]}
2018-07-09 15:17:39:771 - [debug] [W3C] Calling AppiumDriver.keys() with args: [["a"],"e4e92857-219e-4ea3-8ff3-018950f532cd"]
2018-07-09 15:17:39:773 - [debug] [JSONWP Proxy] Proxying [POST /keys] to [POST http://localhost:7085/wd/hub/session/26781bfe-6a42-46ec-aced-8d13e16a3e91/keys] with body: {"text":"a","replace":false,"unicodeKeyboard":true}
2018-07-09 15:17:41:086 - [debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"26781bfe-6a42-46ec-aced-8d13e16a3e91","status":0,"value":""}
2018-07-09 15:17:41:087 - [debug] [MJSONWP] Responding to client with driver.keys() result: null
2018-07-09 15:17:41:088 - [HTTP] <-- POST /wd/hub/session/e4e92857-219e-4ea3-8ff3-018950f532cd/keys 200 1317 ms - 76

#3

Even better example using the Samsung memo to prove it’s not our app under test:

    AppiumDriver<MobileElement> driver = null;
    try {
        DesiredCapabilities cap = new DesiredCapabilities();
        cap.setCapability(CapabilityType.BROWSER_NAME, "");
        cap.setCapability("platformName", "ANDROID");
        cap.setCapability("deviceName", "xxxxxxxxxxx");
        cap.setCapability("platformVersion", "8.0");
        cap.setCapability("appPackage", "com.samsung.android.app.memo");
        cap.setCapability("appActivity", "com.samsung.android.app.memo.Main");
        cap.setCapability("noSign", true);

        driver = new AndroidDriver(new URL(gridURL)), cap);

        MobileElement createBtn = driver.findElement(MobileBy.ById.id("com.samsung.android.app.memo:id/fab_btn"));
        createBtn.click();

        Thread.sleep(2000);

        MobileElement textEntry = driver.findElement(MobileBy.ById.id("com.samsung.android.app.memo:id/editText1"));

        String sendText = "Test This";
        for (String s : sendText.split("")) {
            textEntry.sendKeys(s);
        }
    } finally {
        if (driver != null) {
            driver.quit();
        }
    }

It looks like the appium server is trying to clear for some reason

2018-07-09 15:39:15:885 - [HTTP] --> POST /wd/hub/session/95b158a8-ae25-4d03-8729-414175faaea9/element/2/value
2018-07-09 15:39:15:885 - [HTTP] {"id":"2","value":["T"]}
2018-07-09 15:39:15:886 - [debug] [W3C] Calling AppiumDriver.setValue() with args: [["T"],"2","95b158a8-ae25-4d03-8729-414175faaea9"]
2018-07-09 15:39:15:887 - [debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:setText","params":{"elementId":"2","text":"T","replace":false}}
2018-07-09 15:39:15:890 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"2","text":"T","replace":false}}
2018-07-09 15:39:15:891 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
2018-07-09 15:39:15:892 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: setText
2018-07-09 15:39:15:892 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using element passed in: 2
2018-07-09 15:39:15:902 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Attempting to clear using UiObject.clearText().
2018-07-09 15:39:18:491 - [HTTP] 
2018-07-09 15:39:18:532 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Text remains after clearing, but it appears to be hint text.
2018-07-09 15:39:18:541 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Text not cleared. Assuming remainder is hint text.
2018-07-09 15:39:18:545 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Sending plain text to element: T
2018-07-09 15:39:20:973 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
2018-07-09 15:39:20:973 - [debug] [AndroidBootstrap] Received command result from bootstrap
2018-07-09 15:39:20:974 - [debug] [MJSONWP] Responding to client with driver.setValue() result: true
2018-07-09 15:39:20:974 - [HTTP] <-- POST /wd/hub/session/95b158a8-ae25-4d03-8729-414175faaea9/element/2/value 200 5090 ms - 76

#4

setValue potentially works… but this seems backwards

2018-07-09 15:46:06:297 - [HTTP] --> POST /wd/hub/session/769ab415-73d4-4077-96a2-9f7531e10141/appium/element/2/value
2018-07-09 15:46:06:297 - [HTTP] {"id":"2","value":"t"}
2018-07-09 15:46:06:298 - [debug] [W3C] Calling AppiumDriver.setValueImmediate() with args: ["t","2","769ab415-73d4-4077-96a2-9f7531e10141"]
2018-07-09 15:46:06:299 - [debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:click","params":{"elementId":"2"}}
2018-07-09 15:46:06:302 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"2"}}
2018-07-09 15:46:06:303 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
2018-07-09 15:46:06:303 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: click
2018-07-09 15:46:09:926 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
2018-07-09 15:46:09:926 - [debug] [AndroidBootstrap] Received command result from bootstrap
2018-07-09 15:46:09:927 - [debug] [ADB] Running '/Users/bedouglas/build_tools/android-sdk-macosx-r24.4.1/platform-tools/adb -P 5037 -s ce0117115d52a73f04 shell input text t'
2018-07-09 15:46:10:276 - [HTTP] 
2018-07-09 15:46:10:441 - [debug] [MJSONWP] Responding to client with driver.setValueImmediate() result: null
2018-07-09 15:46:10:442 - [HTTP] <-- POST /wd/hub/session/769ab415-73d4-4077-96a2-9f7531e10141/appium/element/2/value 200 4145 ms - 76

#5

i use GO Keyboard, don’t forget to change the keyboard in your code


#6

Thanks,

Sorry – forgot to mention this is with the keyboard off / Appium Unicode keyboard


#7

Very interesting find… and no clue why they’re different… but with the memo app I’m trying to use to test, I see setValueImmediate use adb:

2018-07-09 16:22:44:348 - [HTTP] --> POST /wd/hub/session/7a899b2c-3499-4b43-a600-91eb9bd255f9/appium/element/2/value
2018-07-09 16:22:44:349 - [HTTP] {"id":"2","value":"Test"}
2018-07-09 16:22:44:349 - [debug] [W3C] Calling AppiumDriver.setValueImmediate() with args: ["Test","2","7a899b2c-3499-4b43-a600-91eb9bd255f9"]
2018-07-09 16:22:44:352 - [debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:click","params":{"elementId":"2"}}
2018-07-09 16:22:44:358 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"2"}}
2018-07-09 16:22:44:359 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
2018-07-09 16:22:44:359 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: click
2018-07-09 16:22:47:498 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
2018-07-09 16:22:47:498 - [debug] [AndroidBootstrap] Received command result from bootstrap
2018-07-09 16:22:47:499 - [debug] [ADB] Running '/Users/bedouglas/build_tools/android-sdk-macosx-r24.4.1/platform-tools/adb -P 5037 -s ce0117115d52a73f04 shell input text Test'
2018-07-09 16:22:47:858 - [HTTP] --> GET /wd/hub/status
2018-07-09 16:22:47:880 - [HTTP] {}
2018-07-09 16:22:47:881 - [debug] [W3C] Calling AppiumDriver.getStatus() with args: []
2018-07-09 16:22:47:894 - [debug] [W3C] Responding to client with driver.getStatus() result: {"build":{"version":"1.8.1","revision":null}}
2018-07-09 16:22:47:895 - [HTTP] <-- GET /wd/hub/status 200 36 ms - 55
2018-07-09 16:22:47:895 - [HTTP] 
2018-07-09 16:22:48:229 - [debug] [MJSONWP] Responding to client with driver.setValueImmediate() result: null
2018-07-09 16:22:48:230 - [HTTP] <-- POST /wd/hub/session/7a899b2c-3499-4b43-a600-91eb9bd255f9/appium/element/2/value 200 3881 ms - 76

But other times it does not

2018-07-09 16:20:19:067 - [HTTP] --> POST /wd/hub/session/25db3dc3-d9c2-49ed-b1b1-14c714b1e5b0/appium/element/ca2a2f44-101f-4602-a243-aae9d604233b/value
2018-07-09 16:20:19:067 - [HTTP] {"id":"ca2a2f44-101f-4602-a243-aae9d604233b","value":"r"}
2018-07-09 16:20:19:068 - [debug] [W3C] Calling AppiumDriver.setValueImmediate() with args: ["r","ca2a2f44-101f-4602-a243-aae9d604233b","25db3dc3-d9c2-49ed-b1b1-14c714b1e5b0"]
2018-07-09 16:20:19:070 - [debug] [JSONWP Proxy] Proxying [POST /element/ca2a2f44-101f-4602-a243-aae9d604233b/value] to [POST http://localhost:7964/wd/hub/session/62832029-963b-4e74-9fab-3218cef4a804/element/ca2a2f44-101f-460
2-a243-aae9d604233b/value] with body: {"elementId":"ca2a2f44-101f-4602-a243-aae9d604233b","text":"r","replace":false,"unicodeKeyboard":true}
2018-07-09 16:20:21:078 - [debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"62832029-963b-4e74-9fab-3218cef4a804","status":0,"value":""}
2018-07-09 16:20:21:079 - [debug] [MJSONWP] Responding to client with driver.setValueImmediate() result: ""
2018-07-09 16:20:21:080 - [HTTP] <-- POST /wd/hub/session/25db3dc3-d9c2-49ed-b1b1-14c714b1e5b0/appium/element/ca2a2f44-101f-4602-a243-aae9d604233b/value 200 2013 ms - 74

I’m wondering if the grid is affecting me since with the test I’m ensuring it’s going on a specific phone… more reasearch to follow


#8

Memo test passes without specifying automationName (Defaults to AndroidDriver (v2.7.0))
Memo test fails specifying automationName as UIAutomator2 (AndroidUiautomator2Driver (v1.12.0))


#9

Reverting back to Appium 1.7.2 (which uses AndroidUiautomator2Driver (v0.11.0)) and using setValue() just clicks on the slement, and calls /value, and UiAutomator2Driver just sends the keys instead of clearing using adb, instead of sending to UiAutomator2 (sendKeys() with Uiautomator2Driver v0.11.0 still clears)

2018-07-10 16:42:03:492 - [HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"appActivity":"com.samsung.android.app.memo.Main","appPackage":"com.samsung.android.app.memo","autoGrantPermissions":true,"automationName":"UIAutomator2","browserName":"","clearSystemFile
s":true,"deviceName":"ce0117115d52a73f04","disableAndroidWatchers":true,"ignoreUnimportantViews":true,"platformName":"android","resetKeyboard":true,"server:CONFIG_UUID":"43f16879-8ba4-4084-aded-92da2b18373d","unicodeKeyboard":true},"capabilities":{"desiredCapabilities"
:{"appActivity":"com.samsung.android.app.memo.Main","appPackage":"com.samsung.android.app.memo","autoGrantPermissions":true,"automationName":"UIAutomator2","browserName":"","clearSystemFiles":true,"deviceName":"ce0117115d52a73f04","disableAndroidWatchers":true,"ignoreU
nimportantViews":true,"platformName":"android","resetKeyboard":true,"server:CONFIG_UUID":"43f16879-8ba4-4084-aded-92da2b18373d","unicodeKeyboard":true},"firstMatch":[{"browserName":"","platformName":"android","server:CONFIG_UUID":"43f16879-8ba4-4084-a
2018-07-10 16:42:03:493 - [debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"appActivity":"com.samsung.android.app.memo.Main","appPackage":"com.samsung.android.app.memo","autoGrantPermissions":true,"automationName":"UIAutomator2","browserName":"","cle
arSystemFiles":true,"deviceName":"ce0117115d52a73f04","disableAndroidWatchers":true,"ignoreUnimportantViews":true,"platformName":"android","resetKeyboard":true,"server:CONFIG_UUID":"43f16879-8ba4-4084-aded-92da2b18373d","unicodeKeyboard":true},null,{"desiredCapabilitie
s":{"appActivity":"com.samsung.android.app.memo.Main","appPackage":"com.samsung.android.app.memo","autoGrantPermissions":true,"automationName":"UIAutomator2","browserName":"","clearSystemFiles":true,"deviceName":"ce0117115d52a73f04","disableAndroidWatchers":true,"ignor
eUnimportantViews":true,"platformName":"android","resetKeyboard":true,"server:CONFIG_UUID":"43f16879-8ba4-4084-aded-92da2b18373d","unicodeKeyboard":true},"firstMatch":[{"browserName":"","platformName":"android","server:CONFIG_UUID":"43f16879-8ba4-4084-aded-92da2b18373d
"}]}]
2018-07-10 16:42:03:494 - [debug] [BaseDriver] Event 'newSessionRequested' logged at 1531240923494 (12:42:03 GMT-0400 (EDT))
2018-07-10 16:42:03:494 - [Appium] Merged W3C capabilities {"desiredCapabilities":{"appActivity":"com.sams... into desiredCapabilities object {"appActivity":"com.samsung.android.app.memo.Ma...
2018-07-10 16:42:03:495 - [Appium] Creating new AndroidUiautomator2Driver (v0.11.0) session
2018-07-10 16:42:03:496 - [Appium] Capabilities:
2018-07-10 16:42:03:496 - [Appium]   appActivity: com.samsung.android.app.memo.Main
2018-07-10 16:42:03:496 - [Appium]   appPackage: com.samsung.android.app.memo
2018-07-10 16:42:03:497 - [Appium]   autoGrantPermissions: true
2018-07-10 16:42:03:497 - [Appium]   automationName: UIAutomator2
2018-07-10 16:42:03:497 - [Appium]   browserName: 
2018-07-10 16:42:03:498 - [Appium]   clearSystemFiles: true
2018-07-10 16:42:03:500 - [Appium]   deviceName: ce0117115d52a73f04
2018-07-10 16:42:03:500 - [Appium]   disableAndroidWatchers: true
2018-07-10 16:42:03:500 - [Appium]   ignoreUnimportantViews: true
2018-07-10 16:42:03:501 - [Appium]   platformName: android
2018-07-10 16:42:03:501 - [Appium]   resetKeyboard: true
2018-07-10 16:42:03:501 - [Appium]   server:CONFIG_UUID: 43f16879-8ba4-4084-aded-92da2b18373d
2018-07-10 16:42:03:501 - [Appium]   unicodeKeyboard: true
2018-07-10 16:42:03:501 - [Appium]   udid: ce0117115d52a73f04
...SNIP...
2018-07-10 16:42:25:165 - [HTTP] --> POST /wd/hub/session/3ca5d001-a73a-4e5c-9354-3ea126534bb9/element/88e8a680-145d-4931-99b4-3b31eb189247/click {"id":"88e8a680-145d-4931-99b4-3b31eb189247"}
2018-07-10 16:42:25:166 - [debug] [MJSONWP] Calling AppiumDriver.click() with args: ["88e8a680-145d-4931-99b4-3b31eb189247","3ca5d001-a73a-4e5c-9354-3ea126534bb9"]
2018-07-10 16:42:25:166 - [debug] [JSONWP Proxy] Proxying [POST /element/88e8a680-145d-4931-99b4-3b31eb189247/click] to [POST http://localhost:8200/wd/hub/session/2a2bdcbf-0437-4659-a735-037b2e96d3ef/element/88e8a680-145d-4931-99b4-3b31eb189247/click] with body: {"element":"88e8a680-145d-4931-99b4-3b31eb189247"}
2018-07-10 16:42:25:255 - [debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"2a2bdcbf-0437-4659-a735-037b2e96d3ef","status":0,"value":true}
2018-07-10 16:42:25:256 - [debug] [MJSONWP] Responding to client with driver.click() result: true
2018-07-10 16:42:25:256 - [HTTP] <-- POST /wd/hub/session/3ca5d001-a73a-4e5c-9354-3ea126534bb9/element/88e8a680-145d-4931-99b4-3b31eb189247/click 200 91 ms - 76 
2018-07-10 16:42:25:267 - [HTTP] --> POST /wd/hub/session/3ca5d001-a73a-4e5c-9354-3ea126534bb9/appium/element/88e8a680-145d-4931-99b4-3b31eb189247/value {"id":"88e8a680-145d-4931-99b4-3b31eb189247","value":"Test"}
2018-07-10 16:42:25:269 - [debug] [MJSONWP] Calling AppiumDriver.setValueImmediate() with args: ["Test","88e8a680-145d-4931-99b4-3b31eb189247","3ca5d001-a73a-4e5c-9354-3ea126534bb9"]
2018-07-10 16:42:25:271 - [debug] [JSONWP Proxy] Proxying [POST /element/88e8a680-145d-4931-99b4-3b31eb189247/click] to [POST http://localhost:8200/wd/hub/session/2a2bdcbf-0437-4659-a735-037b2e96d3ef/element/88e8a680-145d-4931-99b4-3b31eb189247/click] with body: {"element":"88e8a680-145d-4931-99b4-3b31eb189247"}
2018-07-10 16:42:25:836 - [debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"2a2bdcbf-0437-4659-a735-037b2e96d3ef","status":0,"value":true}
2018-07-10 16:42:25:837 - [debug] [ADB] Getting connected devices...
2018-07-10 16:42:25:848 - [debug] [ADB] 2 device(s) connected
2018-07-10 16:42:25:849 - [debug] [ADB] Running '/Users/bedouglas/build_tools/android-sdk-macosx-r24.4.1/platform-tools/adb' with args: ["-P",5037,"-s","ce0117115d52a73f04","shell","input","text","Test"]
2018-07-10 16:42:26:586 - [debug] [MJSONWP] Responding to client with driver.setValueImmediate() result: null
2018-07-10 16:42:26:586 - [HTTP] <-- POST /wd/hub/session/3ca5d001-a73a-4e5c-9354-3ea126534bb9/appium/element/88e8a680-145d-4931-99b4-3b31eb189247/value 200 1319 ms - 76 
2018-07-10 16:42:27:604 - [HTTP] --> POST /wd/hub/session/3ca5d001-a73a-4e5c-9354-3ea126534bb9/appium/element/88e8a680-145d-4931-99b4-3b31eb189247/value {"id":"88e8a680-145d-4931-99b4-3b31eb189247","value":" Thi"}
2018-07-10 16:42:27:605 - [debug] [MJSONWP] Calling AppiumDriver.setValueImmediate() with args: [" Thi","88e8a680-145d-4931-99b4-3b31eb189247","3ca5d001-a73a-4e5c-9354-3ea126534bb9"]
2018-07-10 16:42:27:605 - [debug] [JSONWP Proxy] Proxying [POST /element/88e8a680-145d-4931-99b4-3b31eb189247/click] to [POST http://localhost:8200/wd/hub/session/2a2bdcbf-0437-4659-a735-037b2e96d3ef/element/88e8a680-145d-4931-99b4-3b31eb189247/click] with body: {"element":"88e8a680-145d-4931-99b4-3b31eb189247"}
2018-07-10 16:42:27:700 - [debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"2a2bdcbf-0437-4659-a735-037b2e96d3ef","status":0,"value":true}
2018-07-10 16:42:27:700 - [debug] [ADB] Getting connected devices...
2018-07-10 16:42:27:712 - [debug] [ADB] 2 device(s) connected
2018-07-10 16:42:27:713 - [debug] [ADB] Running '/Users/bedouglas/build_tools/android-sdk-macosx-r24.4.1/platform-tools/adb' with args: ["-P",5037,"-s","ce0117115d52a73f04","shell","input","text","%sThi"]
2018-07-10 16:42:28:378 - [debug] [MJSONWP] Responding to client with driver.setValueImmediate() result: null
2018-07-10 16:42:28:379 - [HTTP] <-- POST /wd/hub/session/3ca5d001-a73a-4e5c-9354-3ea126534bb9/appium/element/88e8a680-145d-4931-99b4-3b31eb189247/value 200 775 ms - 76

#10

Switching to this inside the loop worked… so there’s a workaround… but it’s definitely different

Actions actions = new Actions(driver);
actions.sendKeys(s);
actions.perform();
Thread.sleep(500);

#11

Another update… that doesn’t work when going through Selenium Grid Hub!!! The actions gets translated to sending keys instead, which clears the field

[HTTP] --> POST /wd/hub/session/e240968d-b4d9-4cfc-a4c3-dc41107ed8f8/keys
[HTTP] {"value":["Test"]}
[debug] [W3C] Calling AppiumDriver.keys() with args: [["Test"],"e240968d-b4d9-4cfc-a4c3-dc41107ed8f8"]
[debug] [JSONWP Proxy] Proxying [POST /keys] to [POST http://localhost:8200/wd/hub/session/7f73ed02-3c3f-46f1-88da-2599fc2db6be/keys] with body: {"text":"Test","replace":false,"unicodeKeyboard":true}
[HTTP] --> GET /wd/hub/status
[HTTP] {}
[debug] [W3C] Calling AppiumDriver.getStatus() with args: []
[debug] [W3C] Responding to client with driver.getStatus() result: {"build":{"version":"1.8.1","revision":"60db328d37f79e31065f1d8a697d4594f1d83097"}}
[HTTP] <-- GET /wd/hub/status 200 19 ms - 93
[HTTP] 
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"7f73ed02-3c3f-46f1-88da-2599fc2db6be","status":0,"value":""}
[debug] [MJSONWP] Responding to client with driver.keys() result: null
[HTTP] <-- POST /wd/hub/session/e240968d-b4d9-4cfc-a4c3-dc41107ed8f8/keys 200 1099 ms - 76
[HTTP] 
[HTTP] --> POST /wd/hub/session/e240968d-b4d9-4cfc-a4c3-dc41107ed8f8/keys
[HTTP] {"value":[" Thi"]}
[debug] [W3C] Calling AppiumDriver.keys() with args: [[" Thi"],"e240968d-b4d9-4cfc-a4c3-dc41107ed8f8"]
[debug] [JSONWP Proxy] Proxying [POST /keys] to [POST http://localhost:8200/wd/hub/session/7f73ed02-3c3f-46f1-88da-2599fc2db6be/keys] with body: {"text":" Thi","replace":false,"unicodeKeyboard":true}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"7f73ed02-3c3f-46f1-88da-2599fc2db6be","status":0,"value":""}
[debug] [MJSONWP] Responding to client with driver.keys() result: null
[HTTP] <-- POST /wd/hub/session/e240968d-b4d9-4cfc-a4c3-dc41107ed8f8/keys 200 1073 ms - 76

Locally connected and I see the following in the appium log

2018-07-10 20:43:55:253 - [HTTP] --> POST /wd/hub/session/78934c09-12b1-440c-b7ee-78f40879c204/actions
2018-07-10 20:43:55:253 - [HTTP] {"actions":[{"type":"key","actions":[{"type":"keyDown","value":"T"},{"type":"keyUp","value":"T"},{"type":"keyDown","value":"e"},{"type":"keyUp","value":"e"},{"type":"keyDown","value":"s"},{"type":"keyUp","value":"s"},{"type":"keyDown","value":"t"},{"type":"keyUp","value":"t"}],"id":"default keyboard"}]}
2018-07-10 20:43:55:253 - [debug] [W3C] Calling AppiumDriver.performActions() with args: [[{"type":"key","actions":[{"type":"keyDown","value":"T"},{"type":"keyUp","value":"T"},{"type":"keyDown","value":"e"},{"type":"keyUp","value":"e"},{"type":"keyDown","value":"s"},{"type":"keyUp","value":"s"},{"type":"keyDown","value":"t"},{"type":"keyUp","value":"t"}],"id":"default keyboard"}],"78934c09-12b1-440c-b7ee-78f40879c204"]
2018-07-10 20:43:55:254 - [debug] [UiAutomator2] Received the following W3C actions: [
2018-07-10 20:43:55:255 - [debug] [UiAutomator2]   {
2018-07-10 20:43:55:255 - [debug] [UiAutomator2]     "type": "key",
2018-07-10 20:43:55:255 - [debug] [UiAutomator2]     "actions": [
2018-07-10 20:43:55:255 - [debug] [UiAutomator2]       {
2018-07-10 20:43:55:255 - [debug] [UiAutomator2]         "type": "keyDown",
2018-07-10 20:43:55:255 - [debug] [UiAutomator2]         "value": "T"
2018-07-10 20:43:55:255 - [debug] [UiAutomator2]       },
2018-07-10 20:43:55:255 - [debug] [UiAutomator2]       {
2018-07-10 20:43:55:255 - [debug] [UiAutomator2]         "type": "keyUp",
2018-07-10 20:43:55:255 - [debug] [UiAutomator2]         "value": "T"
2018-07-10 20:43:55:255 - [debug] [UiAutomator2]       },
2018-07-10 20:43:55:256 - [debug] [UiAutomator2]       {
2018-07-10 20:43:55:256 - [debug] [UiAutomator2]         "type": "keyDown",
2018-07-10 20:43:55:256 - [debug] [UiAutomator2]         "value": "e"
2018-07-10 20:43:55:256 - [debug] [UiAutomator2]       },
2018-07-10 20:43:55:256 - [debug] [UiAutomator2]       {
2018-07-10 20:43:55:256 - [debug] [UiAutomator2]         "type": "keyUp",
2018-07-10 20:43:55:256 - [debug] [UiAutomator2]         "value": "e"
2018-07-10 20:43:55:256 - [debug] [UiAutomator2]       },
2018-07-10 20:43:55:256 - [debug] [UiAutomator2]       {
2018-07-10 20:43:55:256 - [debug] [UiAutomator2]         "type": "keyDown",
2018-07-10 20:43:55:256 - [debug] [UiAutomator2]         "value": "s"
2018-07-10 20:43:55:257 - [debug] [UiAutomator2]       },
2018-07-10 20:43:55:257 - [debug] [UiAutomator2]       {
2018-07-10 20:43:55:257 - [debug] [UiAutomator2]         "type": "keyUp",
2018-07-10 20:43:55:257 - [debug] [UiAutomator2]         "value": "s"
2018-07-10 20:43:55:257 - [debug] [UiAutomator2]       },
2018-07-10 20:43:55:257 - [debug] [UiAutomator2]       {
2018-07-10 20:43:55:257 - [debug] [UiAutomator2]         "type": "keyDown",
2018-07-10 20:43:55:257 - [debug] [UiAutomator2]         "value": "t"
2018-07-10 20:43:55:257 - [debug] [UiAutomator2]       },
2018-07-10 20:43:55:257 - [debug] [UiAutomator2]       {
2018-07-10 20:43:55:257 - [debug] [UiAutomator2]         "type": "keyUp",
2018-07-10 20:43:55:258 - [debug] [UiAutomator2]         "value": "t"
2018-07-10 20:43:55:258 - [debug] [UiAutomator2]       }
2018-07-10 20:43:55:258 - [debug] [UiAutomator2]     ],
2018-07-10 20:43:55:258 - [debug] [UiAutomator2]     "id": "default keyboard"
2018-07-10 20:43:55:258 - [debug] [UiAutomator2]   }
2018-07-10 20:43:55:258 - [debug] [UiAutomator2] ]
...SNIP...