javascript - Simulate slow typing in Protractor -
sendkeys()
method send keys @ once (actually, 1 @ time quickly):
var elm = element(by.id("myinput")); elm.sendkeys("test");
is there way slow typing down protractor send one character @ time small delay between each of characters?
we can slow down protractor entirely, not change way sendkeys()
works , slow down while need "send keys" part , in specific cases.
the idea use browser.actions()
, construct series of "send keys" command - 1 every character in string. after every "send keys" command adding delay introducing custom sleep
action. @ end, here reusable function we've come with:
function slowtype(elm, keys, delay) { var action = browser.actions().mousemove(elm).click(); (var = 0; < keys.length; i++) { action = action.sendkeys(keys[i]).sleep(delay); } return action.perform(); }
usage:
slowtype(elm, "some text", 100);
Comments
Post a Comment