The described previously approaches do not work with async/await functions. Here is the method that can be used instead, since Protractor deprecates control flow
/**
* @param {ElementFinder} $element
* @param {string} keys string to type
* @param {number} [delay=200] delay between characters
* @param {number} [timeout=timeouts.ms1000] timeout for waiting for an element to be interactable
*/
slowType: ($element, keys, delay = 200, timeout = 1000) => browser
.wait(
// waits for element to be interactable for 'timeout' ms,
// otherwise throws an error with passed element locator
ExpectedConditions.elementToBeClickable($element),
timeout,
"waitThenSendKeys to " + $element.locator()
).then(() => $element.click())
.then(() => $element.clear())
.then( async () => {
for (let i = 0; i < keys.length; i++) {
await $element.sendKeys(keys[i]);
await browser.sleep(delay);
}
})
Then in your test just import this method (i.e. const {slowType} = require("actions/element-actions");
)
And use the method as follows
await slowType($searchInput, "my search string", 500);