MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / typeValue

Function typeValue

javascript/atoms/action.js:187–211  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

185 keyboard.moveCursor(element);
186
187 function typeValue(value) {
188 if (typeof value === 'string') {
189 goog.array.forEach(value.split(''), function (ch) {
190 var keyShiftPair = bot.Keyboard.Key.fromChar(ch);
191 var shiftIsPressed = keyboard.isPressed(bot.Keyboard.Keys.SHIFT);
192 if (keyShiftPair.shift && !shiftIsPressed) {
193 keyboard.pressKey(bot.Keyboard.Keys.SHIFT);
194 }
195 keyboard.pressKey(keyShiftPair.key);
196 keyboard.releaseKey(keyShiftPair.key);
197 if (keyShiftPair.shift && !shiftIsPressed) {
198 keyboard.releaseKey(bot.Keyboard.Keys.SHIFT);
199 }
200 });
201 } else if (goog.array.contains(bot.Keyboard.MODIFIERS, value)) {
202 if (keyboard.isPressed(/** @type {!bot.Keyboard.Key} */(value))) {
203 keyboard.releaseKey(value);
204 } else {
205 keyboard.pressKey(value);
206 }
207 } else {
208 keyboard.pressKey(value);
209 keyboard.releaseKey(value);
210 }
211 }
212
213 // mobile safari (iPhone / iPad). one cannot 'type' in a date field
214 // chrome implements this, but desktop Safari doesn't, what's webkit again?

Callers 1

action.jsFile · 0.85

Calls 2

splitMethod · 0.80
forEachMethod · 0.45

Tested by

no test coverage detected