Enter Text without SendKeys

As observed , SendKeys is too slow in Appium

Is there any other API/Method to enter text other than Sendkeys which enter text faster?

Hello Every One!

C I expect your valuable replies

Did you try using setValue() ?

((AndroidElement) el).setValue("text");
((AndroidElement) el).replaceValue("text");
((IOSElement) el).setValue("text");

Thanks for your Reply Aleksei.

I am trying to automate only Android App and new to Appium…
Could you send elaborated code(bit in details)

@anandappium sorry did not get what you mean? change “el” to your element and that is all.

tried:

((AndroidElement) patientInfoPage.patientNmeTxt).setValue(“text”);
((AndroidElement) patientInfoPage.patientNmeTxt).replaceValue(“text23”);

where patientInfoPage.patientNmeTxt is WebElement
not working…

any other suggestions,
please

if your client WEB or in WEBVIEW of NATIVE then you need first switch to webview.

You can use adb on Android (I have a custom test method that uses execSync to call ‘adb shell input text’). Watch out for spaces in your strings though - replace them with %s before sending.

Hi Jonesdar,

You mean passing passing text through adb?

Yes. I use the node flavour of Appium so I use wd.addElementPromiseChainMethod() to add a custom method. For iOS that just calls the real sendKeys() - on Android it first clicks on the element and then calls ‘adb shell text input’ to send the text to the element. Note that I didn’t do this for speed (I haven’t compared it to sendKeys) - I did it because when testing a React Native app on the Android emulator sendKeys, setText etc. were not reliable enough. It’s likely that they are now (I set this up about a year ago with a much earlier version of Appium).

Hi Aleksei,
Could you please help out to resolve below

Running ‘C:\Users\cg2\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 0e0919d4e301e977 push C:\Users\jenkins\AppData\Local\Programs\Appium\resources\app\node_modules\appium-android-bootstrap\bootstrap\bin\AppiumBootstrap.jar /data/local/tmp/’
[2018-07-24 09:05:24][ADB] Attempting to kill all uiautomator processes
[2018-07-24 09:05:24][ADB] Getting all processes with uiautomator
[2018-07-24 09:05:24][ADB] Getting connected devices…
[2018-07-24 09:05:25][ADB] 1 device(s) connected
[2018-07-24 09:05:25][ADB] Running ‘C:\Users\cg2\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 0e0919d4e301e977 shell ps’
[2018-07-24 09:05:25][ADB] No uiautomator process found to kill, continuing…
[2018-07-24 09:05:25][UiAutomator] Starting UIAutomator
[2018-07-24 09:05:25][ADB] Creating ADB subprocess with args: ["-P",5037,"-s",“0e0919d4e301e977”,“shell”,“uiautomator”,“runtest”,“AppiumBootstrap.jar”,"-c",“io.appium.android.bootstrap.Bootstrap”,"-e",“pkg”,“com.mdt.hds.consoleUI”,"-e",“disableAndroidWatchers”,false,"-e",“acceptSslCerts”,false]
[2018-07-24 09:05:28][UiAutomator] Moving to state ‘online’
[2018-07-24 09:05:28][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Loading json…
[2018-07-24 09:05:28][AndroidBootstrap] Android bootstrap socket is now connected
[2018-07-24 09:05:28][ADB] Getting connected devices…
[2018-07-24 09:05:28][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Registered crash watchers.
[2018-07-24 09:05:28][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected
[2018-07-24 09:05:28][ADB] 1 device(s) connected
[2018-07-24 09:05:28][ADB] Running ‘C:\Users\cg2\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 0e0919d4e301e977 shell dumpsys window’
[2018-07-24 09:05:28][AndroidDriver] Screen already unlocked, doing nothing
[2018-07-24 09:05:28][ADB] Device API level: 23
[2018-07-24 09:05:28][ADB] Getting connected devices…
[2018-07-24 09:05:28][ADB] 1 device(s) connected
[2018-07-24 09:05:28][ADB] Running ‘C:\Users\cg2\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 0e0919d4e301e977 shell am start -W -n com.mdt.hds.consoleUI/com.mdt.hds.ui.main.HomeScreenActivity -S’
[2018-07-24 09:05:42][Appium] New AndroidDriver session created successfully, session 507d4853-cc1b-4ef4-9f8c-173bf69a291f added to master session list
[2018-07-24 09:05:42][BaseDriver] Event ‘newSessionStarted’ logged at 1532403342432 (09:05:42 GMT+0530 (India Standard Time))
[2018-07-24 09:05:42][MJSONWP] Responding to client with driver.createSession() result: {“platform”:“LINUX”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“appPackage”:“com.mdt.hds.consoleUI”,“appActivity”:“com.mdt.hds.ui.main.HomeScreenActivity”,“noReset”:true,“sendKeyStrategy”:“setValue”,“platformVersion”:“6.0.1”,“unicodeKeyboard”:true,“platformName”:“Android”,“deviceName”:“consoleUIBoard”,“resetKeyboard”:false},“appPackage”:“com.mdt.hds.consoleUI”,“appActivity”:“com.mdt.hds.ui.main.HomeScreenActivity”,“noReset”:true,“sendKeyStrategy”:“setValue”,“platformVersion”:“6.0.1”,“unicodeKeyboard”:true,“platformName”:“Android”,“deviceName”:“0e0919d4e301e977”,“resetKeyboard”:false,“deviceUDID”:“0e0919d4e301e977”,“deviceScreenSize”:“1280x800”,“deviceModel”:“CONSOLEUI-MX6DQ”,“deviceManufacturer”:“Freescale”}
[2018-07-24 09:05:42][HTTP] <-- POST /wd/hub/session 200 48434 ms - 932
[2018-07-24 09:05:42][HTTP]
[2018-07-24 09:06:01][HTTP] --> POST /wd/hub/session/507d4853-cc1b-4ef4-9f8c-173bf69a291f/element
[2018-07-24 09:06:01][HTTP] {“using”:“id”,“value”:“com.mdt.hds.consoleUI:id/PatientInfo_ET_PFirstName”}
[2018-07-24 09:06:01][MJSONWP] Calling AppiumDriver.findElement() with args: [“id”,“com.mdt.hds.consoleUI:id/PatientInfo_ET_PFirstName”,“507d4853-cc1b-4ef4-9f8c-173bf69a291f”]
[2018-07-24 09:06:01][BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[2018-07-24 09:06:01][BaseDriver] Waiting up to 0 ms for condition
[2018-07-24 09:06:01][AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.mdt.hds.consoleUI:id/PatientInfo_ET_PFirstName”,“context”:"",“multiple”:false}}
[2018-07-24 09:06:01][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.mdt.hds.consoleUI:id/PatientInfo_ET_PFirstName”,“context”:"",“multiple”:false}}
[2018-07-24 09:06:01][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[2018-07-24 09:06:01][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[2018-07-24 09:06:01][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.mdt.hds.consoleUI:id/PatientInfo_ET_PFirstName’ using ‘ID’ with the contextId: ‘’ multiple: false
[2018-07-24 09:06:01][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.mdt.hds.consoleUI:id/PatientInfo_ET_PFirstName]
[2018-07-24 09:06:01][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[2018-07-24 09:06:01][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.mdt.hds.consoleUI:id/PatientInfo_ET_PFirstName’ using ‘ID’ with the contextId: ‘’ multiple: false
[2018-07-24 09:06:01][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.mdt.hds.consoleUI:id/PatientInfo_ET_PFirstName]
[2018-07-24 09:06:01][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[2018-07-24 09:06:01][AndroidBootstrap] Received command result from bootstrap
[2018-07-24 09:06:01][MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[2018-07-24 09:06:01][HTTP] <-- POST /wd/hub/session/507d4853-cc1b-4ef4-9f8c-173bf69a291f/element 500 803 ms - 164
[2018-07-24 09:06:01][HTTP]
[2018-07-24 09:06:02][HTTP] --> DELETE /wd/hub/session/507d4853-cc1b-4ef4-9f8c-173bf69a291f
[2018-07-24 09:06:02][HTTP] {}
[2018-07-24 09:06:02][MJSONWP] Calling AppiumDriver.deleteSession() with args: [“507d4853-cc1b-4ef4-9f8c-173bf69a291f”]
[2018-07-24 09:06:02][BaseDriver] Event ‘quitSessionRequested’ logged at 1532403361997 (09:06:01 GMT+0530 (India Standard Time))
[2018-07-24 09:06:02][Appium] Removing session 507d4853-cc1b-4ef4-9f8c-173bf69a291f from our master session list
[2018-07-24 09:06:02][AndroidDriver] Shutting down Android driver
[2018-07-24 09:06:02][ADB] Getting connected devices…
[2018-07-24 09:06:02][ADB] 1 device(s) connected
[2018-07-24 09:06:02][ADB] Running ‘C:\Users\cg2\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 0e0919d4e301e977 shell am force-stop com.mdt.hds.consoleUI’
[2018-07-24 09:06:10][ADB] Pressing the HOME button
[2018-07-24 09:06:10][ADB] Getting connected devices…
[2018-07-24 09:06:10][ADB] 1 device(s) connected
[2018-07-24 09:06:10][ADB] Running ‘C:\Users\cg2\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 0e0919d4e301e977 shell input keyevent 3’
[2018-07-24 09:06:13][AndroidBootstrap] Sending command to android: {“cmd”:“shutdown”}
[2018-07-24 09:06:13][AndroidBootstrap] Received command result from bootstrap
[2018-07-24 09:06:13][UiAutomator] Shutting down UiAutomator
[2018-07-24 09:06:13][UiAutomator] Moving to state ‘stopping’
[2018-07-24 09:06:13][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“shutdown”}
[2018-07-24 09:06:13][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN
[2018-07-24 09:06:13][AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:0,“value”:“OK, shutting down”}
[2018-07-24 09:06:13][UiAutomator] UiAutomator shut down normally
[2018-07-24 09:06:13][UiAutomator] Moving to state ‘stopped’
[2018-07-24 09:06:13][ADB] Attempting to kill all uiautomator processes
[2018-07-24 09:06:13][ADB] Getting all processes with uiautomator
[2018-07-24 09:06:13][ADB] Getting connected devices…
[2018-07-24 09:06:13][ADB] 1 device(s) connected
[2018-07-24 09:06:13][ADB] Running ‘C:\Users\cg2\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 0e0919d4e301e977 shell ps’
[2018-07-24 09:06:13][ADB] No uiautomator process found to kill, continuing…
[2018-07-24 09:06:13][UiAutomator] Moving to state ‘stopped’
[2018-07-24 09:06:13][Logcat] Stopping logcat capture
[2018-07-24 09:06:13][ADB] Getting connected devices…
[2018-07-24 09:06:13][ADB] 1 device(s) connected
[2018-07-24 09:06:13][ADB] Running ‘C:\Users\cg2\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 0e0919d4e301e977 shell am force-stop io.appium.unlock’
[2018-07-24 09:06:16][AndroidDriver] Not cleaning generated files. Add clearSystemFiles capability if wanted.
[2018-07-24 09:06:16][BaseDriver] Event ‘quitSessionFinished’ logged at 1532403376545 (09:06:16 GMT+0530 (India Standard Time))
[2018-07-24 09:06:16][MJSONWP] Received response: null
[2018-07-24 09:06:16][MJSONWP] But deleting session, so not returning
[2018-07-24 09:06:16][MJSONWP] Responding to client with driver.deleteSession() result: null
[2018-07-24 09:06:16][HTTP] <-- DELETE /wd/hub/session/507d4853-cc1b-4ef4-9f8c-173bf69a291f 200 14553 ms - 76
[2018-07-24 09:06:16][HTTP]

After executing few scripts, execution is stopping

I was going to suggest an alternative method for “Enter Text without SendKeys”… .You could try injecting some JavaScript or jQuery to get the job done:

JavascriptExecutor js = (JavascriptExecutor) appDriver;
js.executeScript(“$(‘#fooElement’).val(‘some text’)”);

Good Luck!